Update genetic impl
This commit is contained in:
@@ -69,6 +69,7 @@ namespace Managing.Application.Backtesting
|
||||
/// <param name="user">The user running the backtest (optional)</param>
|
||||
/// <param name="save">Whether to save the backtest results</param>
|
||||
/// <param name="withCandles">Whether to include candles and indicators values in the response</param>
|
||||
/// <param name="requestId">The request ID to associate with this backtest (optional)</param>
|
||||
/// <returns>The backtest results</returns>
|
||||
public async Task<Backtest> RunTradingBotBacktest(
|
||||
TradingBotConfig config,
|
||||
@@ -76,12 +77,13 @@ namespace Managing.Application.Backtesting
|
||||
DateTime endDate,
|
||||
User user = null,
|
||||
bool save = false,
|
||||
bool withCandles = false)
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
{
|
||||
var account = await GetAccountFromConfig(config);
|
||||
var candles = GetCandles(account, config.Ticker, config.Timeframe, startDate, endDate);
|
||||
|
||||
var result = await RunBacktestWithCandles(config, candles, user, withCandles);
|
||||
var result = await RunBacktestWithCandles(config, candles, user, withCandles, requestId);
|
||||
|
||||
// Set start and end dates
|
||||
result.StartDate = startDate;
|
||||
@@ -108,9 +110,10 @@ namespace Managing.Application.Backtesting
|
||||
TradingBotConfig config,
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false)
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
{
|
||||
return await RunBacktestWithCandles(config, candles, user, withCandles);
|
||||
return await RunBacktestWithCandles(config, candles, user, withCandles, requestId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -120,7 +123,8 @@ namespace Managing.Application.Backtesting
|
||||
TradingBotConfig config,
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false)
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
{
|
||||
var tradingBot = _botFactory.CreateBacktestTradingBot(config);
|
||||
|
||||
@@ -136,7 +140,7 @@ namespace Managing.Application.Backtesting
|
||||
tradingBot.User = user;
|
||||
await tradingBot.LoadAccount();
|
||||
|
||||
var result = await GetBacktestingResult(config, tradingBot, candles, user, withCandles);
|
||||
var result = await GetBacktestingResult(config, tradingBot, candles, user, withCandles, requestId);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
@@ -178,7 +182,8 @@ namespace Managing.Application.Backtesting
|
||||
ITradingBot bot,
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false)
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
{
|
||||
if (candles == null || candles.Count == 0)
|
||||
{
|
||||
@@ -267,7 +272,8 @@ namespace Managing.Application.Backtesting
|
||||
? AggregateValues(indicatorsValues, bot.IndicatorsValues)
|
||||
: new Dictionary<IndicatorType, IndicatorsResultBase>(),
|
||||
Score = score,
|
||||
Id = Guid.NewGuid().ToString()
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
RequestId = requestId
|
||||
};
|
||||
|
||||
// Send notification if backtest meets criteria
|
||||
|
||||
@@ -293,7 +293,8 @@ public class TradingBotFitness : IFitness
|
||||
_request.EndDate,
|
||||
_request.User,
|
||||
false, // Don't save individual backtests
|
||||
false // Don't include candles
|
||||
false, // Don't include candles
|
||||
_request.RequestId
|
||||
).Result;
|
||||
|
||||
// Calculate fitness based on backtest results
|
||||
|
||||
Reference in New Issue
Block a user