I open a long order with tp and sl , I want to know if it hit the take profit or stop loss (status closed) for open another order
I use this code but he return filled
from binance.um_futures import UMFutures
def check_order_status(order_id): # true sil atouché stoploss ou takeprofit – false sil est toujours ouvert
global symbol
try:
order = um_futures_client.query_order(
symbol=symbol, orderId=order_id, recvWindow=6000
)
print(order)
# Verifier si l’ordre a ete rempli (et donc ferme)
if order[‘status’] == “FILLED”:
print(“premier L’ordre a ete rempli.”)
return True
# Verifier si le stop-loss a ete touche
if order['status'] == "STOP_LOSS_HIT":
print("premier Le stop-loss a ete touche.")
return True
# Verifier si le take-profit a ete touche
if order['status'] == "TAKE_PROFIT_HIT":
print("premier Le take-profit a ete touche.")
return True
return False
except Exception as e:
print("Erreur lors de la verification de l'etat de l'ordre:", e)
return False