open_orders prefiltered before hitting the orders

This commit is contained in:
Nicolás Sánchez 2026-06-04 16:52:05 -03:00
parent e888ee0c78
commit 9391f18051
3 changed files with 8 additions and 3 deletions

View File

@ -6,6 +6,7 @@
. Decorator for api endpoints error handling . Decorator for api endpoints error handling
. Input validation in api parameters . Input validation in api parameters
. credentials.py import fallback . credentials.py import fallback
. open_orders prefiltered before hitting the traders
2026.06.03: 2026.06.03:
. Fixed tp mode 2 non-functional . Fixed tp mode 2 non-functional

View File

@ -336,9 +336,12 @@ def main_routine():
pairs_to_fetch.append(instance.status.get_pair()) pairs_to_fetch.append(instance.status.get_pair())
open_orders = broker.fetch_open_orders(pairs_to_fetch) open_orders = broker.fetch_open_orders(pairs_to_fetch)
open_orders_by_pair = {}
for order in open_orders:
open_orders_by_pair.setdefault(order["symbol"], []).append(order)
with traders_lock: with traders_lock:
for instance in running_traders: for instance in running_traders:
future = executor.submit(instance.check_status, open_orders) future = executor.submit(instance.check_status, open_orders_by_pair)
futures.append(future) futures.append(future)
online_pairs.append(f"{instance.base}{instance.quote}") online_pairs.append(f"{instance.base}{instance.quote}")

View File

@ -1099,7 +1099,7 @@ class trader:
return (base_left*price)+self.status.get_quote_spent()>=old_target return (base_left*price)+self.status.get_quote_spent()>=old_target
def check_status(self,open_orders: list) -> int: #Should I change the order? Check the SO first? def check_status(self,open_orders: dict) -> int: #Should I change the order? Check the SO first?
''' '''
Main routine. It checks for closed orders and proceeds accordingly. Main routine. It checks for closed orders and proceeds accordingly.
''' '''
@ -1128,7 +1128,8 @@ class trader:
#Extract ids from order list #Extract ids from order list
self.status.set_pause_reason("filtering open orders") self.status.set_pause_reason("filtering open orders")
open_orders_list = [order for order in open_orders if order["symbol"]==self.status.get_pair()] #open_orders_list = [order for order in open_orders if order["symbol"]==self.status.get_pair()]
open_orders_list = open_orders.get(self.status.get_pair(),[])
open_orders_ids = [order["id"] for order in open_orders_list] open_orders_ids = [order["id"] for order in open_orders_list]
self.status.set_pause_reason("check if tp_order is valid") self.status.set_pause_reason("check if tp_order is valid")