I’m using CCXT library for my trading bot. The bot has an object Position with enter_order: Order
, take_profit: Order
and stop_loss: Order
objects. Whenever either take_profit
or stop_loss
order is fully filled I want to mark the position as closed. For this purpose I use CCXT’s watch_orders
method that receives updates from websocket for open orders.
The bot just had open short position and take profit order was triggered and fully filled on the exchange.
The bot received only those two consecutive order updates
1st response:
{"info": {"s": "ARUSDT", "c": "x-xcKtGhcu8d664ade3897e0710bb5b3", "S": "BUY", "o": "TAKE_PROFIT", "f": "GTC", "q": "1.3", "p": "14.669", "ap": "0", "sp": "14.669", "x": "EXPIRED", "X": "EXPIRED", "i": 6549403749, "l": "0", "z": "0", "L": "0", "n": "0", "N": "USDT", "T": 1737461011910, "t": 0, "b": "0", "a": "0", "m": false, "R": true, "wt": "CONTRACT_PRICE", "ot": "TAKE_PROFIT", "ps": "SHORT", "cp": false, "rp": "0", "pP": false, "si": 0, "ss": 0, "V": "EXPIRE_MAKER", "pm": "NONE", "gtd": 0}, "symbol": "AR/USDT:USDT", "id": "6549403749", "clientOrderId": "x-xcKtGhcu8d664ade3897e0710bb5b3", "timestamp": null, "datetime": null, "lastTradeTimestamp": null, "lastUpdateTimestamp": 1737461011910, "type": "take_profit", "timeInForce": "GTC", "postOnly": false, "reduceOnly": true, "side": "buy", "price": 14.669, "stopPrice": 14.669, "triggerPrice": 14.669, "amount": 1.3, "cost": 0.0, "average": null, "filled": 0.0, "remaining": 1.3, "status": "expired", "fee": null, "trades": [], "fees": [], "takeProfitPrice": null, "stopLossPrice": null}
2nd response:
{"info": {"s": "ARUSDT", "c": "x-xcKtGhcu8d664ade3897e0710bb5b3", "S": "BUY", "o": "LIMIT", "f": "GTC", "q": "1.3", "p": "14.669", "ap": "0", "sp": "14.669", "x": "NEW", "X": "NEW", "i": 6549403749, "l": "0", "z": "0", "L": "0", "n": "0", "N": "USDT", "T": 1737461011914, "t": 0, "b": "19.0697", "a": "0", "m": false, "R": true, "wt": "CONTRACT_PRICE", "ot": "TAKE_PROFIT", "ps": "SHORT", "cp": false, "rp": "0", "pP": false, "si": 0, "ss": 0, "V": "EXPIRE_MAKER", "pm": "NONE", "gtd": 0}, "symbol": "AR/USDT:USDT", "id": "6549403749", "clientOrderId": "x-xcKtGhcu8d664ade3897e0710bb5b3", "timestamp": 1737461011914, "datetime": "2025-01-21T12:03:31.914Z", "lastTradeTimestamp": null, "lastUpdateTimestamp": 1737461011914, "type": "limit", "timeInForce": "GTC", "postOnly": false, "reduceOnly": true, "side": "buy", "price": 14.669, "stopPrice": 14.669, "triggerPrice": 14.669, "amount": 1.3, "cost": 0.0, "average": null, "filled": 0.0, "remaining": 1.3, "status": "open", "fee": null, "trades": [], "fees": [], "takeProfitPrice": null, "stopLossPrice": null}
Both of them have "filled": 0.0
and status as either open
or "EXPIRED"
.
Why the order is “EXPIRED” and the filled amount is 0.0
when in the Binance App I can see that the take profit order was fully filled and position was successfully closed?