Add bundle backtest refact + fix whitelist
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#nullable enable
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Managing.Domain.Users;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Domain model for bundle backtest requests
|
||||
/// Domain model for bundle backtest requests with variant-based configuration
|
||||
/// </summary>
|
||||
public class BundleBacktestRequest
|
||||
{
|
||||
@@ -14,7 +15,10 @@ public class BundleBacktestRequest
|
||||
CreatedAt = DateTime.UtcNow;
|
||||
Status = BundleBacktestRequestStatus.Pending;
|
||||
Results = new List<string>();
|
||||
BacktestRequestsJson = string.Empty;
|
||||
UniversalConfigJson = string.Empty;
|
||||
DateTimeRangesJson = string.Empty;
|
||||
MoneyManagementVariantsJson = string.Empty;
|
||||
TickerVariantsJson = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -27,7 +31,10 @@ public class BundleBacktestRequest
|
||||
CreatedAt = DateTime.UtcNow;
|
||||
Status = BundleBacktestRequestStatus.Pending;
|
||||
Results = new List<string>();
|
||||
BacktestRequestsJson = string.Empty;
|
||||
UniversalConfigJson = string.Empty;
|
||||
DateTimeRangesJson = string.Empty;
|
||||
MoneyManagementVariantsJson = string.Empty;
|
||||
TickerVariantsJson = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -66,10 +73,28 @@ public class BundleBacktestRequest
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of backtest requests to execute (serialized as JSON)
|
||||
/// The universal configuration that applies to all backtests (serialized as JSON)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string BacktestRequestsJson { get; set; } = string.Empty;
|
||||
public string UniversalConfigJson { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The list of DateTime ranges to test (serialized as JSON)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string DateTimeRangesJson { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The list of money management variants to test (serialized as JSON)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string MoneyManagementVariantsJson { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The list of ticker variants to test (serialized as JSON)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string TickerVariantsJson { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The results of the bundle backtest execution
|
||||
@@ -118,6 +143,7 @@ public class BundleBacktestRequest
|
||||
/// Estimated time remaining in seconds
|
||||
/// </summary>
|
||||
public int? EstimatedTimeRemainingSeconds { get; set; }
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
118
src/Managing.Domain/Backtests/BundleBacktestUniversalConfig.cs
Normal file
118
src/Managing.Domain/Backtests/BundleBacktestUniversalConfig.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
#nullable enable
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Universal configuration that applies to all backtests in the bundle
|
||||
/// </summary>
|
||||
public class BundleBacktestUniversalConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// The account name to use for all backtests
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string AccountName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The timeframe for trading decisions
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Timeframe Timeframe { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether this bot is for watching only (no actual trading)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public bool IsForWatchingOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The initial trading balance for the bot
|
||||
/// </summary>
|
||||
[Required]
|
||||
public decimal BotTradingBalance { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name/identifier for this bot
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string BotName { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to flip positions
|
||||
/// </summary>
|
||||
[Required]
|
||||
public bool FlipPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cooldown period between trades (in candles)
|
||||
/// </summary>
|
||||
public int? CooldownPeriod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum consecutive losses before stopping the bot
|
||||
/// </summary>
|
||||
public int MaxLossStreak { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The scenario configuration (takes precedence over ScenarioName)
|
||||
/// </summary>
|
||||
public ScenarioRequest? Scenario { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The scenario name to load from database (only used when Scenario is not provided)
|
||||
/// </summary>
|
||||
public string? ScenarioName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum time in hours that a position can remain open before being automatically closed
|
||||
/// </summary>
|
||||
public decimal? MaxPositionTimeHours { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Whether to close positions early when they become profitable
|
||||
/// </summary>
|
||||
public bool CloseEarlyWhenProfitable { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to only flip positions when the current position is in profit
|
||||
/// </summary>
|
||||
public bool FlipOnlyWhenInProfit { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use Synth API for predictions and risk assessment
|
||||
/// </summary>
|
||||
public bool UseSynthApi { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use Synth predictions for position sizing adjustments
|
||||
/// </summary>
|
||||
public bool UseForPositionSizing { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use Synth predictions for signal filtering
|
||||
/// </summary>
|
||||
public bool UseForSignalFiltering { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to use Synth predictions for dynamic stop-loss/take-profit adjustments
|
||||
/// </summary>
|
||||
public bool UseForDynamicStopLoss { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to only watch the backtest without executing trades
|
||||
/// </summary>
|
||||
public bool WatchOnly { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to save the backtest results
|
||||
/// </summary>
|
||||
public bool Save { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to include candles and indicators values in the response.
|
||||
/// Note: This is always ignored for bundle backtests - candles are never returned.
|
||||
/// </summary>
|
||||
public bool WithCandles { get; set; } = false;
|
||||
}
|
||||
22
src/Managing.Domain/Backtests/DateTimeRange.cs
Normal file
22
src/Managing.Domain/Backtests/DateTimeRange.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
#nullable enable
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a date range for backtesting
|
||||
/// </summary>
|
||||
public class DateTimeRange
|
||||
{
|
||||
/// <summary>
|
||||
/// The start date for the backtest
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end date for the backtest
|
||||
/// </summary>
|
||||
[Required]
|
||||
public DateTime EndDate { get; set; }
|
||||
}
|
||||
13
src/Managing.Domain/Backtests/MoneyManagementVariant.cs
Normal file
13
src/Managing.Domain/Backtests/MoneyManagementVariant.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
#nullable enable
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a money management variant for backtesting
|
||||
/// </summary>
|
||||
public class MoneyManagementVariant
|
||||
{
|
||||
/// <summary>
|
||||
/// The money management details
|
||||
/// </summary>
|
||||
public MoneyManagementRequest MoneyManagement { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user