Refactor StartBotCommandHandler to conditionally check trading_future feature flag based on trading type. This change ensures that the feature flag validation is only performed for Futures and BacktestFutures trading types, improving the handling of bot configuration.
This commit is contained in:
@@ -29,18 +29,21 @@ namespace Managing.Application.ManageBot
|
|||||||
|
|
||||||
public async Task<BotStatus> Handle(StartBotCommand request, CancellationToken cancellationToken)
|
public async Task<BotStatus> Handle(StartBotCommand request, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Check if trading_future feature flag is enabled
|
// Validate the configuration
|
||||||
|
if (request.Config == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Bot configuration is required");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if trading_future feature flag is enabled (only for Futures trading types)
|
||||||
|
if (request.Config.TradingType == TradingType.Futures || request.Config.TradingType == TradingType.BacktestFutures)
|
||||||
|
{
|
||||||
var isTradingFutureEnabled = await _flagsmithService.IsFeatureEnabledAsync(request.User.Name, "trading_future");
|
var isTradingFutureEnabled = await _flagsmithService.IsFeatureEnabledAsync(request.User.Name, "trading_future");
|
||||||
if (!isTradingFutureEnabled)
|
if (!isTradingFutureEnabled)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
"Futures trading is not enabled for your account. Please contact support to enable this feature.");
|
"Futures trading is not enabled for your account. Please contact support to enable this feature.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the configuration
|
|
||||||
if (request.Config == null)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Bot configuration is required");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (request.Config.Scenario == null || !request.Config.Scenario.Indicators.Any())
|
if (request.Config.Scenario == null || !request.Config.Scenario.Indicators.Any())
|
||||||
|
|||||||
Reference in New Issue
Block a user