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

@@ -139,6 +139,11 @@ public class BotController : BaseController
await NotifyBotSubscriberAsync();
return Ok(result);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("already have a strategy"))
{
// Return 400 for validation errors about existing strategies on same ticker
return BadRequest(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error starting bot");
@@ -168,6 +173,11 @@ public class BotController : BaseController
await NotifyBotSubscriberAsync();
return Ok(result);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("already have a strategy"))
{
// Return 400 for validation errors about existing strategies on same ticker
return BadRequest(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error starting copy trading bot");
@@ -192,6 +202,11 @@ public class BotController : BaseController
return Ok(result);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("already have a strategy"))
{
// Return 400 for validation errors about existing strategies on same ticker
return BadRequest(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error saving bot");
@@ -319,6 +334,11 @@ public class BotController : BaseController
return Ok(result);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("already have another strategy"))
{
// Return 400 for validation errors about existing strategies on same ticker
return BadRequest(ex.Message);
}
catch (Exception ex)
{
_logger.LogError(ex, "Error restarting bot");