Add filters and sorting for backtests

This commit is contained in:
2025-10-14 18:06:36 +07:00
parent 49b0f7b696
commit 74adad5834
21 changed files with 4028 additions and 81 deletions

View File

@@ -332,13 +332,22 @@ public static class PostgreSqlMappers
GrowthPercentage = backtest.GrowthPercentage,
HodlPercentage = backtest.HodlPercentage,
ConfigJson = JsonConvert.SerializeObject(backtest.Config),
Name = backtest.Config?.Name ?? string.Empty,
Ticker = backtest.Config?.Ticker.ToString() ?? string.Empty,
Timeframe = (int)backtest.Config.Timeframe,
IndicatorsCsv = string.Join(',', backtest.Config.Scenario.Indicators.Select(i => i.Type.ToString())),
IndicatorsCount = backtest.Config.Scenario.Indicators.Count,
PositionsJson = JsonConvert.SerializeObject(backtest.Positions.Values.ToList()),
SignalsJson = JsonConvert.SerializeObject(backtest.Signals.Values.ToList()),
StartDate = backtest.StartDate,
EndDate = backtest.EndDate,
Duration = backtest.EndDate - backtest.StartDate,
MoneyManagementJson = JsonConvert.SerializeObject(backtest.Config?.MoneyManagement),
UserId = backtest.User?.Id ?? 0,
StatisticsJson = backtest.Statistics != null ? JsonConvert.SerializeObject(backtest.Statistics) : null,
SharpeRatio = backtest.Statistics?.SharpeRatio ?? 0m,
MaxDrawdown = backtest.Statistics?.MaxDrawdown ?? 0m,
MaxDrawdownRecoveryTime = backtest.Statistics?.MaxDrawdownRecoveryTime ?? TimeSpan.Zero,
Fees = backtest.Fees,
Score = backtest.Score,
ScoreMessage = backtest.ScoreMessage ?? string.Empty,
@@ -976,4 +985,13 @@ public static class PostgreSqlMappers
}
#endregion
private static int? ExtractBundleIndex(string name)
{
if (string.IsNullOrWhiteSpace(name)) return null;
var hashIndex = name.LastIndexOf('#');
if (hashIndex < 0 || hashIndex + 1 >= name.Length) return null;
var numberPart = name.Substring(hashIndex + 1).Trim();
return int.TryParse(numberPart, out var n) ? n : (int?)null;
}
}