Refactor BacktestSpotBot signal generation to utilize base implementation for optimizations; update BacktestExecutorTests with revised metrics reflecting recent backtest results; add new performance benchmark entries for improved tracking.

This commit is contained in:
2025-12-19 18:00:37 +07:00
parent b52f00a450
commit 415845ed5a
4 changed files with 16 additions and 14 deletions

View File

@@ -163,13 +163,11 @@ public class BacktestSpotBot : TradingBotBase, ITradingBot
protected override async Task UpdateSignalsCore(IReadOnlyList<Candle> candles,
Dictionary<IndicatorType, IndicatorsResultBase> preCalculatedIndicatorValues = null)
{
// For spot trading, always fetch signals regardless of open positions
// Check if we're in cooldown period
if (await IsInCooldownPeriodAsync())
{
// Still in cooldown period, skip signal generation
return;
}
// Call base implementation for common optimizations (flip check, cooldown check)
// This will return early if:
// - FlipPosition is disabled AND there's an open position
// - Bot is in cooldown period
await base.UpdateSignalsCore(candles, preCalculatedIndicatorValues);
// For backtest, if no candles provided (called from Run()), skip signal generation
// Signals are generated in BacktestExecutor with rolling window candles

View File

@@ -576,14 +576,14 @@ public class BacktestExecutorTests : BaseTests, IDisposable
// Validate key metrics - Updated with actual backtest results
Assert.Equal(1000.0m, result.InitialBalance);
Assert.Equal(-71.63m, Math.Round(result.FinalPnl, 2));
Assert.Equal(16, result.WinRate);
Assert.Equal(-10.86m, Math.Round(result.GrowthPercentage, 2));
Assert.Equal(-42.10m, Math.Round(result.FinalPnl, 2));
Assert.Equal(22, result.WinRate);
Assert.Equal(-6.48m, Math.Round(result.GrowthPercentage, 2));
Assert.Equal(-0.67m, Math.Round(result.HodlPercentage, 2));
Assert.Equal(32.59m, Math.Round(result.Fees, 2));
Assert.Equal(-108.65m, Math.Round(result.NetPnl, 2));
Assert.Equal(111.76m, Math.Round((decimal)result.MaxDrawdown, 2));
Assert.Equal(-0.107, Math.Round((double)(result.SharpeRatio ?? 0), 3));
Assert.Equal(20.01m, Math.Round(result.Fees, 2));
Assert.Equal(-64.81m, Math.Round(result.NetPnl, 2));
Assert.Equal(75.63m, Math.Round((decimal)result.MaxDrawdown, 2));
Assert.Equal(-0.045, Math.Round((double)(result.SharpeRatio ?? 0), 3));
Assert.True(Math.Abs(result.Score - 0.0) < 0.001,
$"Score {result.Score} should be within 0.001 of expected value 0.0");

View File

@@ -18,3 +18,5 @@ DateTime,TestName,CandlesCount,ExecutionTimeSeconds,ProcessingRateCandlesPerSec,
2025-12-01T10:49:46Z,Telemetry_ETH_RSI_EMACROSS,5760,2.94,1962.1,28.94,37.41,39.55,0.0,0,0.0,0.0,0.0,0.0,-30567.20,20,-45.32,0.00,93dc3e37,refactor-trading-bot,development
2025-12-01T10:50:15Z,Telemetry_ETH_RSI_EMACROSS,5760,2.98,1935.6,28.91,37.35,39.49,0.0,0,0.0,0.0,0.0,0.0,-30567.20,20,-45.32,0.00,93dc3e37,refactor-trading-bot,development
2025-12-01T10:50:46Z,Telemetry_ETH_RSI_EMACROSS,5760,2.30,2508.3,28.92,37.35,39.50,0.0,0,0.0,0.0,0.0,0.0,-30567.20,20,-45.32,0.00,93dc3e37,refactor-trading-bot,development
2025-12-19T10:11:32Z,Telemetry_ETH_RSI_EMACROSS,5760,18.57,310.2,28.99,14.21,35.78,0.0,0,0.0,0.0,0.0,0.0,-30567.20,20,-45.32,0.00,b52f00a4,dev,development
2025-12-19T10:54:33Z,Telemetry_ETH_RSI_EMACROSS,5760,4.93,1167.2,29.23,13.62,38.13,0.0,0,0.0,0.0,0.0,0.0,-30567.20,20,-45.32,0.00,b52f00a4,dev,development
1 DateTime TestName CandlesCount ExecutionTimeSeconds ProcessingRateCandlesPerSec MemoryStartMB MemoryEndMB MemoryPeakMB SignalUpdatesCount SignalUpdatesSkipped SignalUpdateEfficiencyPercent BacktestStepsCount AverageSignalUpdateMs AverageBacktestStepMs FinalPnL WinRatePercent GrowthPercentage Score CommitHash GitBranch Environment
18 2025-12-01T10:49:46Z Telemetry_ETH_RSI_EMACROSS 5760 2.94 1962.1 28.94 37.41 39.55 0.0 0 0.0 0.0 0.0 0.0 -30567.20 20 -45.32 0.00 93dc3e37 refactor-trading-bot development
19 2025-12-01T10:50:15Z Telemetry_ETH_RSI_EMACROSS 5760 2.98 1935.6 28.91 37.35 39.49 0.0 0 0.0 0.0 0.0 0.0 -30567.20 20 -45.32 0.00 93dc3e37 refactor-trading-bot development
20 2025-12-01T10:50:46Z Telemetry_ETH_RSI_EMACROSS 5760 2.30 2508.3 28.92 37.35 39.50 0.0 0 0.0 0.0 0.0 0.0 -30567.20 20 -45.32 0.00 93dc3e37 refactor-trading-bot development
21 2025-12-19T10:11:32Z Telemetry_ETH_RSI_EMACROSS 5760 18.57 310.2 28.99 14.21 35.78 0.0 0 0.0 0.0 0.0 0.0 -30567.20 20 -45.32 0.00 b52f00a4 dev development
22 2025-12-19T10:54:33Z Telemetry_ETH_RSI_EMACROSS 5760 4.93 1167.2 29.23 13.62 38.13 0.0 0 0.0 0.0 0.0 0.0 -30567.20 20 -45.32 0.00 b52f00a4 dev development

View File

@@ -21,3 +21,5 @@ DateTime,TestName,CandlesCount,ExecutionTimeSeconds,ProcessingRateCandlesPerSec,
2025-12-01T10:49:46Z,Telemetry_ETH_RSI,5760,1.585,3624.2,28.91,24.57,40.82,1458.82,0,0.0,81.56,0.00,0.01,-9933.44,26,-36.30,0.00,93dc3e37,refactor-trading-bot,development
2025-12-01T10:50:15Z,Telemetry_ETH_RSI,5760,1.565,3670.7,28.90,24.34,41.31,1457.61,0,0.0,66.48,0.00,0.01,-9933.44,26,-36.30,0.00,93dc3e37,refactor-trading-bot,development
2025-12-01T10:50:46Z,Telemetry_ETH_RSI,5760,1.67,3442.1,28.90,23.95,41.13,1548.30,0,0.0,78.60,0.00,0.01,-9933.44,26,-36.30,0.00,93dc3e37,refactor-trading-bot,development
2025-12-19T10:11:32Z,Telemetry_ETH_RSI,5760,8.885,647.5,29.01,23.79,40.69,7622.36,0,0.0,879.40,0.00,0.15,-9933.44,26,-36.30,0.00,b52f00a4,dev,development
2025-12-19T10:54:33Z,Telemetry_ETH_RSI,5760,8.05,713.6,29.03,15.69,33.22,6980.81,0,0.0,802.29,0.00,0.14,-9933.44,26,-36.30,0.00,b52f00a4,dev,development
1 DateTime TestName CandlesCount ExecutionTimeSeconds ProcessingRateCandlesPerSec MemoryStartMB MemoryEndMB MemoryPeakMB SignalUpdatesCount SignalUpdatesSkipped SignalUpdateEfficiencyPercent BacktestStepsCount AverageSignalUpdateMs AverageBacktestStepMs FinalPnL WinRatePercent GrowthPercentage Score CommitHash GitBranch Environment
21 2025-12-01T10:49:46Z Telemetry_ETH_RSI 5760 1.585 3624.2 28.91 24.57 40.82 1458.82 0 0.0 81.56 0.00 0.01 -9933.44 26 -36.30 0.00 93dc3e37 refactor-trading-bot development
22 2025-12-01T10:50:15Z Telemetry_ETH_RSI 5760 1.565 3670.7 28.90 24.34 41.31 1457.61 0 0.0 66.48 0.00 0.01 -9933.44 26 -36.30 0.00 93dc3e37 refactor-trading-bot development
23 2025-12-01T10:50:46Z Telemetry_ETH_RSI 5760 1.67 3442.1 28.90 23.95 41.13 1548.30 0 0.0 78.60 0.00 0.01 -9933.44 26 -36.30 0.00 93dc3e37 refactor-trading-bot development
24 2025-12-19T10:11:32Z Telemetry_ETH_RSI 5760 8.885 647.5 29.01 23.79 40.69 7622.36 0 0.0 879.40 0.00 0.15 -9933.44 26 -36.30 0.00 b52f00a4 dev development
25 2025-12-19T10:54:33Z Telemetry_ETH_RSI 5760 8.05 713.6 29.03 15.69 33.22 6980.81 0 0.0 802.29 0.00 0.14 -9933.44 26 -36.30 0.00 b52f00a4 dev development