wrong tp order code

This commit is contained in:
Nicolás Sánchez 2025-09-05 16:44:38 -03:00
parent 05b46203ab
commit 61a3545dd7
1 changed files with 10 additions and 9 deletions

View File

@ -1161,15 +1161,16 @@ class trader:
self.status.set_pause_reason("check if tp_order is filled") self.status.set_pause_reason("check if tp_order is filled")
#Checks if the take profit order is filled #Checks if the take profit order is filled
if self.status.get_take_profit_order()["id"] not in open_orders_ids: if self.status.get_take_profit_order()["id"] not in open_orders_ids:
# # I hate Kucoin: # Check if the order has a wrong id. If so, update the order.
# # Check if the order has a wrong id. If so, update the order. # To cover a very rare case that happens if the trader sends a new take profit order but is interrupted before saving the status.
# for order in open_orders: # Not sure if it is worth to keep this code.
# if order["amount"]==self.status.get_take_profit_order()["amount"] and order["price"]==self.status.get_take_profit_order()["price"] and order["side"]==self.status.get_take_profit_order()["side"]: for order in open_orders:
# #Right order, wrong id. Update order if order["amount"]==self.status.get_take_profit_order()["amount"] and order["price"]==self.status.get_take_profit_order()["price"] and order["side"]==self.status.get_take_profit_order()["side"]:
# self.broker.logger.log_this(f"Updating take profit order for {self.status.get_pair()}",1,self.status.get_pair()) #Right order, wrong id. Update order
# self.status.set_take_profit_order(order) self.broker.logger.log_this(f"Updating take profit order for {self.status.get_pair()}",1,self.status.get_pair())
# self.update_status(True) self.status.set_take_profit_order(order)
# return 0 self.update_status(True)
return 0
tp_status = self.broker.get_order(self.status.get_take_profit_order()["id"],self.status.get_pair()) tp_status = self.broker.get_order(self.status.get_take_profit_order()["id"],self.status.get_pair())
if tp_status["status"]=="closed": if tp_status["status"]=="closed":