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:
2026-01-07 01:44:05 +07:00
parent a0859b6a0d
commit bc4725ca19
3 changed files with 8 additions and 4 deletions

View File

@@ -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()