From ba3b784236d0effc93bc447d233223b3d04c4b7a Mon Sep 17 00:00:00 2001 From: Carlos Wu Fei Date: Wed, 3 Jan 2024 18:58:08 +0100 Subject: [PATCH] Prevent signals opening pairs that are already active --- api/deals/controllers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/api/deals/controllers.py b/api/deals/controllers.py index 3c0e34a34..8ee380a5a 100644 --- a/api/deals/controllers.py +++ b/api/deals/controllers.py @@ -332,6 +332,15 @@ def open_deal(self): - If base order deal is not executed, bot is not activated """ + # Check if bot with same pair is already active + active_bot = self.db_collection.find_one( + {"pair": self.active_bot.pair, "status": Status.active} + ) + if active_bot: + raise CreateDealControllerError( + f"Bot with pair {self.active_bot.pair} is already active" + ) + # If there is already a base order do not execute base_order_deal = next( (