How to find which order is the exit order corresponding to the entry order in Fyers API?

I’m placing an order using Fyers API v3, and initially, it’s in a Pending state. I track its status using the Orders API. Suppose this order gets filled/traded at 11:00 AM, and the position is exited at 12:00 PM.

Now, using the Order Book API, how can I determine which order is the exit order corresponding to the entry order placed at 11:00 AM?

One approach is to match orders based on the side and symbol fields from Orders API response — for example:

  • 11:00 AM: side = 1 (Buy), symbol = NSE:NIFTY2570326900CE
  • 12:00 PM: side = -1 (Sell), symbol = NSE:NIFTY2570326900CE

However, this logic breaks down when trading the same symbol multiple times in a day — e.g., if another Buy-Sell trade happens between 2:00 PM and 3:00 PM, the Sell order at 3:00 PM (Exit) might incorrectly match with the Buy (Entry) at 11:00 AM.

I also checked the Positions API, but the orderId returned by the place_order API doesn’t appear in the Positions API response.

Hey @ylnCU3hvDm ,

Whenever you are placing an order there is a Orderid generated , you can use that id to see the corresponding counter order you’ve placed to close that position .

How can I see the corresponding counter order using the entry Orderid? In the response of order book, I was not able to find the entry Orderid, on my exit order record