Add bundle backtest
This commit is contained in:
@@ -59,6 +59,12 @@ public class BundleBacktestRequest
|
||||
[Required]
|
||||
public BundleBacktestRequestStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Display name for the bundle backtest request
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The list of backtest requests to execute (serialized as JSON)
|
||||
/// </summary>
|
||||
@@ -143,4 +149,4 @@ public enum BundleBacktestRequestStatus
|
||||
/// Request was cancelled
|
||||
/// </summary>
|
||||
Cancelled
|
||||
}
|
||||
}
|
||||
73
src/Managing.Domain/Backtests/IndicatorRequest.cs
Normal file
73
src/Managing.Domain/Backtests/IndicatorRequest.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Request model for indicator configuration without user information
|
||||
/// </summary>
|
||||
public class IndicatorRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the indicator
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The type of indicator
|
||||
/// </summary>
|
||||
[Required]
|
||||
public IndicatorType Type { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The signal type for this indicator
|
||||
/// </summary>
|
||||
[Required]
|
||||
public SignalType SignalType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Minimum history required for this indicator
|
||||
/// </summary>
|
||||
public int MinimumHistory { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Period parameter for the indicator
|
||||
/// </summary>
|
||||
public int? Period { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Fast periods parameter for indicators like MACD
|
||||
/// </summary>
|
||||
public int? FastPeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Slow periods parameter for indicators like MACD
|
||||
/// </summary>
|
||||
public int? SlowPeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Signal periods parameter for indicators like MACD
|
||||
/// </summary>
|
||||
public int? SignalPeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Multiplier parameter for indicators like SuperTrend
|
||||
/// </summary>
|
||||
public double? Multiplier { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Smooth periods parameter
|
||||
/// </summary>
|
||||
public int? SmoothPeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Stochastic periods parameter
|
||||
/// </summary>
|
||||
public int? StochPeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cycle periods parameter
|
||||
/// </summary>
|
||||
public int? CyclePeriods { get; set; }
|
||||
}
|
||||
13
src/Managing.Domain/Backtests/MoneyManagementRequest.cs
Normal file
13
src/Managing.Domain/Backtests/MoneyManagementRequest.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Managing.Common;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
public class MoneyManagementRequest
|
||||
{
|
||||
[Required] public string Name { get; set; }
|
||||
[Required] public Enums.Timeframe Timeframe { get; set; }
|
||||
[Required] public decimal StopLoss { get; set; }
|
||||
[Required] public decimal TakeProfit { get; set; }
|
||||
[Required] public decimal Leverage { get; set; }
|
||||
}
|
||||
56
src/Managing.Domain/Backtests/RunBacktestRequest.cs
Normal file
56
src/Managing.Domain/Backtests/RunBacktestRequest.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using Managing.Domain.Bots;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Request model for running a backtest
|
||||
/// </summary>
|
||||
public class RunBacktestRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The trading bot configuration request to use for the backtest
|
||||
/// </summary>
|
||||
public TradingBotConfigRequest Config { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The start date for the backtest
|
||||
/// </summary>
|
||||
public DateTime StartDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The end date for the backtest
|
||||
/// </summary>
|
||||
public DateTime EndDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The starting balance for the backtest
|
||||
/// </summary>
|
||||
public decimal Balance { get; set; }
|
||||
|
||||
/// <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.
|
||||
/// Set to false to reduce response size dramatically.
|
||||
/// </summary>
|
||||
public bool WithCandles { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// The name of the money management to use (optional if MoneyManagement is provided)
|
||||
/// </summary>
|
||||
public string? MoneyManagementName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The money management details (optional if MoneyManagementName is provided)
|
||||
/// </summary>
|
||||
public MoneyManagement? MoneyManagement { get; set; }
|
||||
}
|
||||
26
src/Managing.Domain/Backtests/ScenarioRequest.cs
Normal file
26
src/Managing.Domain/Backtests/ScenarioRequest.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Managing.Domain.Backtests;
|
||||
|
||||
/// <summary>
|
||||
/// Request model for scenario configuration without user information
|
||||
/// </summary>
|
||||
public class ScenarioRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The name of the scenario
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// List of indicator configurations for this scenario
|
||||
/// </summary>
|
||||
[Required]
|
||||
public List<IndicatorRequest> Indicators { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// The loopback period for the scenario
|
||||
/// </summary>
|
||||
public int? LoopbackPeriod { get; set; }
|
||||
}
|
||||
116
src/Managing.Domain/Bots/TradingBotConfigRequest.cs
Normal file
116
src/Managing.Domain/Bots/TradingBotConfigRequest.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Managing.Domain.Backtests;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Domain.Bots;
|
||||
|
||||
/// <summary>
|
||||
/// Simplified trading bot configuration request with only primary properties
|
||||
/// </summary>
|
||||
public class TradingBotConfigRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// The account name to use for trading
|
||||
/// </summary>
|
||||
[Required]
|
||||
public string AccountName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ticker/symbol to trade
|
||||
/// </summary>
|
||||
[Required]
|
||||
public Ticker Ticker { get; set; }
|
||||
|
||||
/// <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 Name { get; set; }
|
||||
|
||||
[Required] public bool FlipPosition { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Cooldown period between trades (in candles)
|
||||
/// </summary>
|
||||
[Required]
|
||||
public int CooldownPeriod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum consecutive losses before stopping the bot
|
||||
/// </summary>
|
||||
[Required]
|
||||
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>
|
||||
/// The money management name to load from database (only used when MoneyManagement is not provided)
|
||||
/// </summary>
|
||||
public string? MoneyManagementName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The money management object to use for the bot
|
||||
/// </summary>
|
||||
public MoneyManagementRequest? MoneyManagement { 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;
|
||||
}
|
||||
Reference in New Issue
Block a user