Backtest stop when balance below 10usd

This commit is contained in:
2025-07-17 22:57:13 +07:00
parent 6873e570c1
commit 0a4acf9b9a

View File

@@ -265,6 +265,16 @@ namespace Managing.Application.Backtesting
currentCandle++;
// Check if wallet balance fell below 10 USDC and break if so
var currentWalletBalance = bot.WalletBalances.Values.LastOrDefault();
if (currentWalletBalance < 10m)
{
_logger.LogWarning(
"Backtest stopped early: Wallet balance fell below 10 USDC (Current: {CurrentBalance:F2} USDC) at candle {CurrentCandle}/{TotalCandles} from {CandleDate}",
currentWalletBalance, currentCandle, totalCandles, candle.Date.ToString("yyyy-MM-dd HH:mm"));
break;
}
// Log progress every 10% or every 1000 candles, whichever comes first
var currentPercentage = (int)((double)currentCandle / totalCandles * 100);
var shouldLog = currentPercentage >= lastLoggedPercentage + 10 ||