Add score

This commit is contained in:
2025-03-01 17:24:16 +07:00
parent e16f0a2e5d
commit bcf9d21b0a
7 changed files with 212 additions and 4 deletions

View File

@@ -164,6 +164,23 @@ namespace Managing.Application.Backtesting
var stats = TradingHelpers.GetStatistics(bot.WalletBalances);
var growthPercentage = TradingHelpers.GetGrowthFromInitalBalance(balance, finalPnl);
var hodlPercentage = TradingHelpers.GetHodlPercentage(candles[0], candles.Last());
var scoringParams = new BacktestScoringParams(
sharpeRatio: (double)stats.SharpeRatio,
maxDrawdownPc: (double)stats.MaxDrawdownPc,
growthPercentage: (double)growthPercentage,
hodlPercentage: (double)hodlPercentage,
winRate: winRate,
totalPnL: (double)finalPnl,
fees: (double)bot.GetTotalFees(),
tradeCount: bot.Positions.Count,
maxDrawdownRecoveryTime: stats.MaxDrawdownRecoveryTime
);
// Then calculate the score
var score = BacktestScorer.CalculateTotalScore(scoringParams);
var result = new Backtest(ticker, scenario.Name, bot.Positions, bot.Signals.ToList(), timeframe, candles,
bot.BotType, account.Name)
{
@@ -176,9 +193,11 @@ namespace Managing.Application.Backtesting
Statistics = stats,
OptimizedMoneyManagement = optimizedMoneyManagement,
MoneyManagement = moneyManagement,
StrategiesValues = AggregateValues(strategiesValues, bot.StrategiesValues)
StrategiesValues = AggregateValues(strategiesValues, bot.StrategiesValues),
Score = score
};
return result;
}