Block user to create strategy with over allocation

This commit is contained in:
2025-10-03 16:14:24 +07:00
parent 83ee4f633c
commit 6928770da7
3 changed files with 80 additions and 0 deletions

View File

@@ -72,6 +72,14 @@ namespace Managing.Application.ManageBot
}
}
// Enforce allocation limit across all bots using the same account
var availableAllocation = await _botService.GetAvailableAllocationUsdAsync(account, default);
if (request.Config.BotTradingBalance > availableAllocation)
{
throw new InvalidOperationException(
$"Insufficient available allocation on account '{account.Name}'. Requested: {request.Config.BotTradingBalance:F2} USDC, Available: {availableAllocation:F2} USDC.");
}
try
{
var botGrain = _grainFactory.GetGrain<ILiveTradingBotGrain>(Guid.NewGuid());