Mapping Open and Closed Trade

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? how to find the orderId of the closing of the same position?

Correction : I tried use data from ‘allOrders’

Thanks you !

Hi, I haven’T reach there yet… but I don’t think you have to use the binance generated orderid. There is also the parameter… newClientOrderId => [STRING]

Perhaps the open and close orders can have similar newClientOrderId + a unique string appended to them?

I tried with the newClientOrderId, but it is unique for each order .
I’ve been looking for a solution for days, there must be one, how else would the automatic trading logs work?

I still haven’t found a solution, in fact, I wish I could do this: