Fix solution build
This commit is contained in:
@@ -8,7 +8,6 @@ using Managing.Application.Bots.Base;
|
||||
using Managing.Application.Hubs;
|
||||
using Managing.Application.ManageBot;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Backtests;
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
@@ -177,7 +176,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = moneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -194,7 +193,7 @@ namespace Managing.Application.Tests
|
||||
// Act
|
||||
var backtestResult = await _backtester.RunTradingBotBacktest(config, DateTime.UtcNow.AddDays(-6),
|
||||
DateTime.UtcNow, null, false, false);
|
||||
WriteCsvReport(backtestResult.GetStringReport());
|
||||
// WriteCsvReport(backtestResult.GetStringReport());
|
||||
|
||||
// Assert
|
||||
Assert.True(backtestResult.FinalPnl > 0);
|
||||
@@ -234,10 +233,10 @@ namespace Managing.Application.Tests
|
||||
if (candles == null || candles.Count == 0)
|
||||
return;
|
||||
|
||||
Parallel.For(periodRange[0], periodRange[1], options, i =>
|
||||
Parallel.For((long)periodRange[0], periodRange[1], options, i =>
|
||||
{
|
||||
var scenario = new Scenario("ScalpingScenario");
|
||||
var strategy = ScenarioHelpers.BuildIndicator(indicatorType, "RsiDiv", period: i);
|
||||
var strategy = ScenarioHelpers.BuildIndicator(indicatorType, "RsiDiv", period: (int)i);
|
||||
scenario.AddIndicator(strategy);
|
||||
|
||||
// -0.5 to -5
|
||||
@@ -267,7 +266,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = moneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -285,7 +284,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = moneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -304,10 +303,10 @@ namespace Managing.Application.Tests
|
||||
|
||||
if (backtestResult.FinalPnl > 0
|
||||
&& (backtestResult.GrowthPercentage - backtestResult.HodlPercentage) > 30
|
||||
&& backtestResult.Statistics.MaxDrawdown < 3)
|
||||
&& backtestResult.Score < 3)
|
||||
{
|
||||
var currentResult = new Tuple<string, int, decimal, decimal, decimal, decimal>(
|
||||
ticker.ToString(), i,
|
||||
ticker.ToString(), (int)i,
|
||||
backtestResult.FinalPnl, s, t,
|
||||
backtestResult.GrowthPercentage - backtestResult.HodlPercentage);
|
||||
result.Add(currentResult);
|
||||
@@ -407,7 +406,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = moneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -425,7 +424,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = moneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -442,8 +441,7 @@ namespace Managing.Application.Tests
|
||||
};
|
||||
|
||||
if (backtestResult.FinalPnl > 0
|
||||
&& (backtestResult.GrowthPercentage - backtestResult.HodlPercentage) > 30
|
||||
&& backtestResult.Statistics.MaxDrawdown < 3)
|
||||
&& (backtestResult.GrowthPercentage - backtestResult.HodlPercentage) > 30)
|
||||
{
|
||||
var currentResult = new Tuple<string, decimal, decimal, decimal, decimal>(
|
||||
ticker.ToString(),
|
||||
@@ -661,7 +659,7 @@ namespace Managing.Application.Tests
|
||||
AccountName = _account.Name,
|
||||
MoneyManagement = standardMoneyManagement,
|
||||
Ticker = ticker,
|
||||
Scenario = scenario,
|
||||
Scenario = LightScenario.FromScenario(scenario),
|
||||
Timeframe = timeframe,
|
||||
IsForWatchingOnly = false,
|
||||
BotTradingBalance = 1000,
|
||||
@@ -679,24 +677,6 @@ namespace Managing.Application.Tests
|
||||
|
||||
timer.Stop();
|
||||
|
||||
var scoringParams = new BacktestScoringParams(
|
||||
sharpeRatio: (double)(backtestResult.Statistics?.SharpeRatio ?? 0),
|
||||
growthPercentage: (double)backtestResult.GrowthPercentage,
|
||||
hodlPercentage: (double)backtestResult.HodlPercentage,
|
||||
winRate: backtestResult.WinRate / 100.0, // Convert percentage to decimal
|
||||
totalPnL: (double)backtestResult.FinalPnl,
|
||||
fees: (double)backtestResult.Fees,
|
||||
tradeCount: backtestResult.Positions?.Count ?? 0,
|
||||
maxDrawdownRecoveryTime: backtestResult.Statistics?.MaxDrawdownRecoveryTime ?? TimeSpan.Zero,
|
||||
maxDrawdown: backtestResult.Statistics?.MaxDrawdown ?? 0,
|
||||
initialBalance: config.BotTradingBalance,
|
||||
tradingBalance: config.BotTradingBalance,
|
||||
startDate: backtestResult.StartDate,
|
||||
endDate: backtestResult.EndDate,
|
||||
timeframe: config.Timeframe,
|
||||
moneyManagement: config.MoneyManagement
|
||||
);
|
||||
|
||||
var scenarioResult = new ScenarioBacktestResult
|
||||
{
|
||||
ScenarioName = scenario.Name,
|
||||
@@ -708,14 +688,13 @@ namespace Managing.Application.Tests
|
||||
GrowthPercentage = backtestResult.GrowthPercentage,
|
||||
HodlPercentage = backtestResult.HodlPercentage,
|
||||
OutperformanceVsHodl = backtestResult.GrowthPercentage - backtestResult.HodlPercentage,
|
||||
MaxDrawdown = (double)(backtestResult.Statistics?.MaxDrawdown ?? 0),
|
||||
TotalTrades = backtestResult.Positions?.Count ?? 0,
|
||||
SharpeRatio = (double)(backtestResult.Statistics?.SharpeRatio ?? 0),
|
||||
MaxDrawdown = (double)(backtestResult.MaxDrawdown ?? 0),
|
||||
SharpeRatio = (double)(backtestResult.SharpeRatio ?? 0),
|
||||
ExecutionTime = timer.Elapsed.TotalSeconds,
|
||||
StopLoss = standardMoneyManagement.StopLoss,
|
||||
TakeProfit = standardMoneyManagement.TakeProfit,
|
||||
Leverage = standardMoneyManagement.Leverage,
|
||||
Score = BacktestScorer.CalculateTotalScore(scoringParams)
|
||||
Score = backtestResult.Score,
|
||||
};
|
||||
|
||||
results.Add(scenarioResult);
|
||||
|
||||
Reference in New Issue
Block a user