Backtest stop when balance below 10usd
This commit is contained in:
@@ -265,6 +265,16 @@ namespace Managing.Application.Backtesting
|
|||||||
|
|
||||||
currentCandle++;
|
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
|
// Log progress every 10% or every 1000 candles, whichever comes first
|
||||||
var currentPercentage = (int)((double)currentCandle / totalCandles * 100);
|
var currentPercentage = (int)((double)currentCandle / totalCandles * 100);
|
||||||
var shouldLog = currentPercentage >= lastLoggedPercentage + 10 ||
|
var shouldLog = currentPercentage >= lastLoggedPercentage + 10 ||
|
||||||
|
|||||||
Reference in New Issue
Block a user