Refactor FuturesBot and SpotBot to utilize ticker enum for candle retrieval
- Updated GetCurrentCandleForPositionClose method in both FuturesBot and SpotBot to parse the ticker parameter into an enum, enhancing type safety and clarity. - Adjusted TradingBotBase to use the position's ticker for candle retrieval, ensuring consistency across trading bot implementations.
This commit is contained in:
@@ -143,8 +143,10 @@ public class SpotBot : TradingBotBase
|
||||
protected override async Task<Candle> GetCurrentCandleForPositionClose(Account account, string ticker)
|
||||
{
|
||||
// For live trading, get real-time candle from exchange
|
||||
// ticker parameter is a string representation of the position's ticker
|
||||
var tickerEnum = Enum.Parse<Ticker>(ticker);
|
||||
return await ServiceScopeHelpers.WithScopedService<IExchangeService, Candle>(_scopeFactory,
|
||||
async exchangeService => await exchangeService.GetCandle(Account, Config.Ticker, DateTime.UtcNow));
|
||||
async exchangeService => await exchangeService.GetCandle(Account, tickerEnum, DateTime.UtcNow));
|
||||
}
|
||||
|
||||
protected override async Task<bool> CheckBrokerPositions()
|
||||
|
||||
Reference in New Issue
Block a user