Prevent user to open multiple strategy on the same ticker

This commit is contained in:
2025-11-18 13:58:50 +07:00
parent 87712038ff
commit 0ee190786e
6 changed files with 75 additions and 0 deletions

View File

@@ -72,6 +72,15 @@ namespace Managing.Application.ManageBot
throw new InvalidOperationException($"Could not retrieve configuration for master bot {request.MasterBotIdentifier}");
}
// Check if user already has a bot on this ticker (same as master bot)
var hasExistingBotOnTicker = await _botService.HasUserBotOnTickerAsync(request.User.Id, masterConfig.Ticker);
if (hasExistingBotOnTicker)
{
throw new InvalidOperationException(
$"You already have a strategy running or saved on ticker {masterConfig.Ticker}. " +
"You cannot create multiple strategies on the same ticker.");
}
// Get account information from the requesting user's accounts
var userAccounts = await _accountService.GetAccountsByUserAsync(request.User, true, true);
var firstAccount = userAccounts.FirstOrDefault();