From 68ac6003611e3cb64adc079e4cefb8986546a42b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sat, 31 May 2025 20:02:01 -0300 Subject: [PATCH] liquidate_after_switch in status --- status_handler.py | 11 +++++++++++ trader.py | 1 + 2 files changed, 12 insertions(+) diff --git a/status_handler.py b/status_handler.py index 42b79c4..e758cd1 100644 --- a/status_handler.py +++ b/status_handler.py @@ -37,6 +37,7 @@ class StatusHandler: "deal_start_time": 0, "stop_when_profit": False, "autoswitch": False, + "liquidate_after_switch": False, "old_long": {}, "pause_reason": "", "status_string": "", @@ -130,6 +131,9 @@ class StatusHandler: def get_autoswitch(self): return self.status_dictionary["autoswitch"] + def get_liquidate_after_switch(self): + return self.status_dictionary["liquidate_after_switch"] + def get_old_long(self): return self.status_dictionary["old_long"] @@ -343,6 +347,13 @@ class StatusHandler: self.status_dictionary["autoswitch"] = switch return 0 + def set_liquidate_after_switch(self, switch: bool): + # if not isinstance(switch, bool): + # self.broker.logger.log_this(f"value provided is not a boolean",1,self.get_pair()) + # return 1 + self.status_dictionary["liquidate_after_switch"] = switch + return 0 + def set_old_long(self, old_long: dict): # if not isinstance(old_long, dict): # self.broker.logger.log_this(f"value provided is not a dictionary",1,self.get_pair()) diff --git a/trader.py b/trader.py index 85d63e9..caeada7 100755 --- a/trader.py +++ b/trader.py @@ -298,6 +298,7 @@ class trader: self.status.set_tp_mode(self.config.get_tp_mode()) self.status.set_profit_table(self.config.get_tp_table()) self.status.set_autoswitch(self.config.get_autoswitch()) + self.status.set_liquidate_after_switch(self.config.get_liquidate_after_switch()) except Exception as e: self.broker.logger.log_this(f"Can't update status dictionary. Exception: {e}",1,self.config.get_pair()) return 1