Mapping Open and Closed Trade in Binance API

Hi !

I need some help with Binance API. I building code for analysis trading activity. My target is know how to map the original order with order to closed original order in Futures market

Example:

  • First: I open Long BTCUSDT → binance generated orderid: 1111
  • Now I close current long position → new order was generate example: orderid = 2222

So now how can i use binance api to get this pair of order?

Correction : I tried use data from ‘allOrders’

Thanks you !

https://binance-docs.github.io/apidocs/futures/en/#query-order-user_data

You can use the query order endpoint using the symbol and orderId as parameter.

I don’t see how to solve my problem. From the orderId 1111 (which is the opening of the position) how to find the orderId of the closing of the same position?

Or is there not an endpoint where I can find the opening and closing information of a position?