Add metadata to backtest
This commit is contained in:
@@ -70,6 +70,7 @@ namespace Managing.Application.Backtesting
|
||||
/// <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>
|
||||
/// <param name="metadata">Additional metadata to associate with this backtest (optional)</param>
|
||||
/// <returns>The backtest results</returns>
|
||||
public async Task<Backtest> RunTradingBotBacktest(
|
||||
TradingBotConfig config,
|
||||
@@ -78,11 +79,12 @@ namespace Managing.Application.Backtesting
|
||||
User user = null,
|
||||
bool save = false,
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
string requestId = null,
|
||||
object metadata = null)
|
||||
{
|
||||
var candles = GetCandles(config.Ticker, config.Timeframe, startDate, endDate);
|
||||
|
||||
var result = await RunBacktestWithCandles(config, candles, user, withCandles, requestId);
|
||||
var result = await RunBacktestWithCandles(config, candles, user, withCandles, requestId, metadata);
|
||||
|
||||
// Set start and end dates
|
||||
result.StartDate = startDate;
|
||||
@@ -110,9 +112,10 @@ namespace Managing.Application.Backtesting
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
string requestId = null,
|
||||
object metadata = null)
|
||||
{
|
||||
return await RunBacktestWithCandles(config, candles, user, withCandles, requestId);
|
||||
return await RunBacktestWithCandles(config, candles, user, withCandles, requestId, metadata);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,7 +126,8 @@ namespace Managing.Application.Backtesting
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
string requestId = null,
|
||||
object metadata = null)
|
||||
{
|
||||
var tradingBot = _botFactory.CreateBacktestTradingBot(config);
|
||||
|
||||
@@ -139,7 +143,7 @@ namespace Managing.Application.Backtesting
|
||||
tradingBot.User = user;
|
||||
await tradingBot.LoadAccount();
|
||||
|
||||
var result = await GetBacktestingResult(config, tradingBot, candles, user, withCandles, requestId);
|
||||
var result = await GetBacktestingResult(config, tradingBot, candles, user, withCandles, requestId, metadata);
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
@@ -182,7 +186,8 @@ namespace Managing.Application.Backtesting
|
||||
List<Candle> candles,
|
||||
User user = null,
|
||||
bool withCandles = false,
|
||||
string requestId = null)
|
||||
string requestId = null,
|
||||
object metadata = null)
|
||||
{
|
||||
if (candles == null || candles.Count == 0)
|
||||
{
|
||||
@@ -272,7 +277,8 @@ namespace Managing.Application.Backtesting
|
||||
: new Dictionary<IndicatorType, IndicatorsResultBase>(),
|
||||
Score = score,
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
RequestId = requestId
|
||||
RequestId = requestId,
|
||||
Metadata = metadata
|
||||
};
|
||||
|
||||
// Send notification if backtest meets criteria
|
||||
|
||||
Reference in New Issue
Block a user