TraderBot: Add an ability to buy or sell with its own price #267
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements the ability for TraderBot to buy or sell at its own price instead of waiting in long queues at the best bid/ask prices. This addresses issue #222 where traders want to avoid waiting in queues by paying a small premium to cross the spread partially.
Key Features
Implementation Details
New Configuration Settings
EnableCustomBuyPrice: Boolean to enable/disable the feature (default: false)CustomBuyPriceSpreadPercentage: Percentage of spread to cross (default: 50.0%)MaxCustomBuyPriceSteps: Maximum price steps above best bid (default: 10 steps)Price Calculation Logic
The custom buy price is calculated as:
bestBid + (spread * percentage / 100)min(customPrice, bestBid + maxSteps * priceStep)min(customPrice, bestAsk)max(customPrice, bestBid)Example Scenarios
Scenario 1 (Feature disabled):
Scenario 2 (50% spread crossing):
Scenario 3 (Limited by max steps):
Files Modified
TradingService.cs: Core trading logic updated to use custom buy priceTradingSettings.cs: Added new configuration propertiesappsettings.TRUR.json&appsettings.TMON.json: Added default configuration valuesexamples/custom_buy_price_test.md: Test scenarios documentationTesting
Benefits
Usage
To enable the feature, set in
appsettings.json:{ "TradingSettings": { "EnableCustomBuyPrice": true, "CustomBuyPriceSpreadPercentage": 50.0, "MaxCustomBuyPriceSteps": 10 } }Fixes #222
🤖 Generated with Claude Code