From c5415a7e8b81c986e0a8c0379c73c58276fdd936 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20S=C3=A1nchez?= Date: Sun, 17 Nov 2024 19:04:47 -0300 Subject: [PATCH] complete order list --- changelog.txt | 3 +++ exchange_wrapper.py | 15 ++++++++------- main.py | 2 +- todo.txt | 11 +++++------ trader.py | 7 +++++-- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/changelog.txt b/changelog.txt index eac1736..5fb9a7d 100755 --- a/changelog.txt +++ b/changelog.txt @@ -1,3 +1,6 @@ +2024.11.17: +. The trader is supplied with a complete open order list, instead of only the ids. + 2024.11.13: . Fixed bug handling timestamps. . Added a couple of pauses for OKX. diff --git a/exchange_wrapper.py b/exchange_wrapper.py index b2b3f75..0098dae 100755 --- a/exchange_wrapper.py +++ b/exchange_wrapper.py @@ -486,14 +486,15 @@ class broker: if pairs is None: pairs = [] try: - id_list = [] + #id_list = [] if self.read_config["exchange"]=="binance": - orders = self.get_opened_orders_binance(pairs) - else: - orders = self.get_opened_orders() - if orders!=[]: - id_list.extend(x["id"] for x in orders) - return id_list + return self.get_opened_orders_binance(pairs) + return self.get_opened_orders() + #else: + # orders = self.get_opened_orders() + #if orders!=[]: + # id_list.extend(x["id"] for x in orders) + #return id_list except Exception as e: self.logger.log_this(f"Exception in fetch_open_orders: {e}",2) return [] diff --git a/main.py b/main.py index d8a1bb0..c3c14de 100644 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ In case the permissions of the certificate changes, reset them this way: # ll /etc/letsencrypt/ ''' -version = "2024.11.13" +version = "2024.11.17" ''' Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors diff --git a/todo.txt b/todo.txt index 75ec6d0..dbdc7e3 100755 --- a/todo.txt +++ b/todo.txt @@ -2,12 +2,11 @@ Mandatory: ========= 0. Mobile app. 1. Stats webpage. -2. Instead of providing a list of order_ids to each trader, provide a list of the open orders for easier future development, including partial order fills. -3. Maintain local orderbooks for each trading pair, which enables: - 3a. Smart order pricing: Prioritization of fill speed over instant profit or vice versa -4. Consolidate vocabulary (trader, pair and bot; instance & trader) -5. Base add for short traders. -6. Proper handling of order price too high/low in OKX (rare, it happens when under heavy volatility). +2. Maintain local orderbooks for each trading pair, which enables: + 2a. Smart order pricing: Prioritization of fill speed over instant profit or vice versa +3. Consolidate vocabulary (trader, pair and bot; instance & trader) +4. Base add for short traders. +5. Proper handling of order price too high/low in OKX (rare, it happens when under heavy volatility). Would be nice to have: diff --git a/trader.py b/trader.py index a14109d..3110ea2 100755 --- a/trader.py +++ b/trader.py @@ -1100,6 +1100,9 @@ class trader: self.update_status(False) return 0 + #Extract ids from order list + open_orders_ids = [order["id"] for order in open_orders if order["symbol"]==self.pair] + #Checks if the orders are valid if self.tp_order is None: self.broker.logger.log_this("Take profit order is None",1,self.pair) @@ -1121,7 +1124,7 @@ class trader: return 1 #Checks if the take profit order is filled - if self.tp_order["id"] not in open_orders: + if self.tp_order["id"] not in open_orders_ids: tp_status = self.broker.get_order(self.tp_order["id"],self.pair) if tp_status["status"]=="closed": if tp_status["filled"]>0: @@ -1150,7 +1153,7 @@ class trader: return 1 # Check if safety order is filled - if self.so["id"] not in open_orders and self.safety_order_index<=self.config_dict["no_of_safety_orders"]: + if self.so["id"] not in open_orders_ids and self.safety_order_index<=self.config_dict["no_of_safety_orders"]: #so_status = self.so #if self.so["id"]!="": so_status = self.broker.get_order(self.so["id"],self.pair)