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.

1
2 replies