I am building a software placing trades via Futures API together with SL and TP orders. Now I want to track, when the order was closed, for what reason it was closed (manual, SL, TP) and at which price (also need the time and PNL).
The “problem” (for me) is, that every closing order gets its own orderID from Binance. I want to build a loop where I am going through all my open orders (in my DB) and check if one of them was closed and if so, get all the data and write it into my DB.
Websocket isn’t really an option, as the software is not running 24/7 and so could miss a lot of notifications.
Any idea how to achieve that?
So far, my only idea was to use GET /fapi/v1/allOrders. But first of all, that could give me thousands of orders in a heavily used account, and second, I would need to identify the correct order using symbol and quantity, but that could also be wrong (maybe there is more than one order with the same specs). Also, the performance wouldn’t be great I guess, and I want to run it continuously.
I would need a possibility to check what happened to a specific orderId, if it’s still open, or closed and if so, why and how. Any chance to realize that?
Any hints are greatly appreciated, stuck here right now…