Stc opti (#15)

* Optimize STC

* Optimize STC

* Add SuperTrendCrossEma
This commit is contained in:
Oda
2025-03-01 02:59:19 +07:00
committed by GitHub
parent c715da8a17
commit e16f0a2e5d
13 changed files with 485 additions and 51 deletions

View File

@@ -153,7 +153,7 @@ namespace Managing.Application.Backtesting
}
bot.Candles = new HashSet<Candle>(candles);
// bot.UpdateStrategiesValues();
bot.UpdateStrategiesValues();
var strategies = _scenarioService.GetStrategies();
var strategiesValues = GetStrategiesValues(strategies, candles);
@@ -176,12 +176,36 @@ namespace Managing.Application.Backtesting
Statistics = stats,
OptimizedMoneyManagement = optimizedMoneyManagement,
MoneyManagement = moneyManagement,
StrategiesValues = strategiesValues
StrategiesValues = AggregateValues(strategiesValues, bot.StrategiesValues)
};
return result;
}
private Dictionary<StrategyType, StrategiesResultBase> AggregateValues(
Dictionary<StrategyType, StrategiesResultBase> strategiesValues,
Dictionary<StrategyType, StrategiesResultBase> botStrategiesValues)
{
// Foreach strategy type, only retrieve the values where the strategy is not present already in the bot
// Then, add the values to the bot values
var result = new Dictionary<StrategyType, StrategiesResultBase>();
foreach (var strategy in strategiesValues)
{
// if (!botStrategiesValues.ContainsKey(strategy.Key))
// {
// result[strategy.Key] = strategy.Value;
// }else
// {
// result[strategy.Key] = botStrategiesValues[strategy.Key];
// }
result[strategy.Key] = strategy.Value;
}
return result;
}
private Dictionary<StrategyType, StrategiesResultBase> GetStrategiesValues(IEnumerable<Strategy> strategies,
List<Candle> candles)
{