From 29dbdce95e563faebc4f732899df7b58ce4a7d10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Wed, 10 Sep 2025 16:21:39 -0300 Subject: [PATCH] 2025.09.10 --- changelog.txt | 3 +++ exchange_wrapper.py | 16 +++++++--------- main.py | 2 +- status_handler.py | 22 ++-------------------- 4 files changed, 13 insertions(+), 30 deletions(-) diff --git a/changelog.txt b/changelog.txt index 6c5c199..7b563f0 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2025.09.10: +. Deal order history now stores only the id of each order instead of the full order object. + 2025.09.08: . Re-enabled long to short autoswitch. diff --git a/exchange_wrapper.py b/exchange_wrapper.py index f37a178..2e97d4f 100755 --- a/exchange_wrapper.py +++ b/exchange_wrapper.py @@ -15,19 +15,17 @@ class Broker: self.exchange = exchange self.last_price = 0 self.wait_time = .5 #Default wait time for API breathing room - self.cooldown_multiplier = 2 #Default cooldown multiplier value - if "cooldown_multiplier" in self.broker_config: - self.cooldown_multiplier = self.broker_config["cooldown_multiplier"] - self.wait_before_new_safety_order = 1 - if "wait_before_new_safety_order" in self.broker_config: - self.wait_before_new_safety_order = self.broker_config["wait_before_new_safety_order"] self.empty_order = {"id": "", "status": "", "filled": 0, "remaining": 0, "price": 0, "cost": 0, "fees": [], "symbol": ""} + + #Default values + self.cooldown_multiplier = self.broker_config["cooldown_multiplier"] if "cooldown_multiplier" in self.broker_config else 2 + self.wait_before_new_safety_order = self.broker_config["wait_before_new_safety_order"] if "wait_before_new_safety_order" in self.broker_config else 1 self.retries = self.broker_config["retries"] if "retries" in self.broker_config else 5 self.slippage_default_threshold = self.broker_config["slippage_default_threshold"] if "slippage_default_threshold" in self.broker_config else .03 + self.follow_order_history = self.broker_config["follow_order_history"] if "follow_order_history" in self.broker_config else False + self.write_order_history = self.broker_config["write_order_history"] if "write_order_history" in self.broker_config else False self.logger = Logger(self.broker_config) - self.follow_order_history = False #This should be a toggle in config_file - self.write_order_history = False #This should be a toggle in config_file - + #Initialize database self.profits_database_filename = "profits/profits_database.db" diff --git a/main.py b/main.py index c8009d0..ec4c182 100644 --- a/main.py +++ b/main.py @@ -18,7 +18,7 @@ import exchange_wrapper import trader -version = "2025.09.09" +version = "2025.09.10" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors diff --git a/status_handler.py b/status_handler.py index b219e4c..1baddec 100644 --- a/status_handler.py +++ b/status_handler.py @@ -421,28 +421,10 @@ class StatusHandler: def update_deal_order_history(self, new_deal: dict): # if not isinstance(new_deal, dict): # self.broker.logger.log_this(f"value provided is not a dict",1,self.get_pair()) - self.status_dictionary["deal_order_history"].append(self.strip_order(new_deal)) + id = new_deal["id"] if "id" in new_deal else None + self.status_dictionary["deal_order_history"].append(id) return 0 - def strip_order(self, order): - try: - stripped_order = {"id": order["id"], - "symbol": order["symbol"], - "type": order["type"], - "side": order["side"], - "price": float(order["price"]), - "amount": float(order["amount"]), - "filled": float(order["filled"]), - "cost": float(order["cost"]), - "remaining": float(order["remaining"]), - "timestamp": order["timestamp"], - "fees": order["fees"]} - return stripped_order - except Exception as e: - self.broker.logger.log_this(f"Error stripping order: {e}",2) - return order - - def save_to_file(self, file_path = None, is_backup = False): if file_path is None: file_path = self.status_file_path