Fix backtest spot

This commit is contained in:
2025-12-03 16:47:32 +07:00
parent c932fef289
commit a07d7ede18
6 changed files with 56 additions and 44 deletions

View File

@@ -536,7 +536,7 @@ public class AgentGrain : Grain, IAgentGrain
}
// Check each bot for open positions
foreach (var botEntry in userBots)
foreach (var botEntry in userBots.Where(b => b.Status == BotStatus.Running))
{
try
{

View File

@@ -173,6 +173,18 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
{
// Handle fallback for empty AccountName before creating the trading bot instance
var config = _state.State.Config;
if (config.TradingType == TradingType.BacktestFutures)
{
config.TradingType = TradingType.Futures;
_state.State.Config = config;
}
else if (config.TradingType == TradingType.BacktestSpot)
{
config.TradingType = TradingType.Spot;
_state.State.Config = config;
}
if (string.IsNullOrEmpty(config.AccountName))
{
// Fallback: Get the first account for the user
@@ -531,7 +543,7 @@ public class LiveTradingBotGrain : Grain, ILiveTradingBotGrain, IRemindable
using var scope = _scopeFactory.CreateScope();
var logger = scope.ServiceProvider.GetRequiredService<ILogger<TradingBotBase>>();
var streamProvider = this.GetStreamProvider("ManagingStreamProvider");
// Create the trading bot instance based on TradingType
TradingBotBase tradingBot = config.TradingType switch
{