complete order list

This commit is contained in:
Nicolás Sánchez 2024-11-17 19:04:47 -03:00
parent 22f7dc292f
commit c5415a7e8b
5 changed files with 22 additions and 16 deletions

View File

@ -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: 2024.11.13:
. Fixed bug handling timestamps. . Fixed bug handling timestamps.
. Added a couple of pauses for OKX. . Added a couple of pauses for OKX.

View File

@ -486,14 +486,15 @@ class broker:
if pairs is None: if pairs is None:
pairs = [] pairs = []
try: try:
id_list = [] #id_list = []
if self.read_config["exchange"]=="binance": if self.read_config["exchange"]=="binance":
orders = self.get_opened_orders_binance(pairs) return self.get_opened_orders_binance(pairs)
else: return self.get_opened_orders()
orders = self.get_opened_orders() #else:
if orders!=[]: # orders = self.get_opened_orders()
id_list.extend(x["id"] for x in orders) #if orders!=[]:
return id_list # id_list.extend(x["id"] for x in orders)
#return id_list
except Exception as e: except Exception as e:
self.logger.log_this(f"Exception in fetch_open_orders: {e}",2) self.logger.log_this(f"Exception in fetch_open_orders: {e}",2)
return [] return []

View File

@ -22,7 +22,7 @@ In case the permissions of the certificate changes, reset them this way:
# ll /etc/letsencrypt/ # 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 Color definitions. If you want to change them, check the reference at https://en.wikipedia.org/wiki/ANSI_escape_code#Colors

View File

@ -2,12 +2,11 @@ Mandatory:
========= =========
0. Mobile app. 0. Mobile app.
1. Stats webpage. 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. 2. Maintain local orderbooks for each trading pair, which enables:
3. Maintain local orderbooks for each trading pair, which enables: 2a. Smart order pricing: Prioritization of fill speed over instant profit or vice versa
3a. Smart order pricing: Prioritization of fill speed over instant profit or vice versa 3. Consolidate vocabulary (trader, pair and bot; instance & trader)
4. Consolidate vocabulary (trader, pair and bot; instance & trader) 4. Base add for short traders.
5. Base add for short traders. 5. Proper handling of order price too high/low in OKX (rare, it happens when under heavy volatility).
6. Proper handling of order price too high/low in OKX (rare, it happens when under heavy volatility).
Would be nice to have: Would be nice to have:

View File

@ -1100,6 +1100,9 @@ class trader:
self.update_status(False) self.update_status(False)
return 0 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 #Checks if the orders are valid
if self.tp_order is None: if self.tp_order is None:
self.broker.logger.log_this("Take profit order is None",1,self.pair) self.broker.logger.log_this("Take profit order is None",1,self.pair)
@ -1121,7 +1124,7 @@ class trader:
return 1 return 1
#Checks if the take profit order is filled #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) tp_status = self.broker.get_order(self.tp_order["id"],self.pair)
if tp_status["status"]=="closed": if tp_status["status"]=="closed":
if tp_status["filled"]>0: if tp_status["filled"]>0:
@ -1150,7 +1153,7 @@ class trader:
return 1 return 1
# Check if safety order is filled # 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 #so_status = self.so
#if self.so["id"]!="": #if self.so["id"]!="":
so_status = self.broker.get_order(self.so["id"],self.pair) so_status = self.broker.get_order(self.so["id"],self.pair)