Exit position if loss or target is achieved

Hello,

I am a beginner in Python coding and I am trying to code exit my all positions when my target or stop loss is achieved via Python. Please help me

if price >= target || price <= stoploss:
   fyers.exit_positions({})

blank dictionary with exit_positions exits every position you have so use carefully

you can pass position ID to exit a specific positions like this

fyers.exit_positions({"id":"NSE:SBIN-EQ-INTRADAY"})

Nihal, its not price, its PnL. This PnL is comprised of several strikes. I may use all strikes or only a few strikes.

What I understand is that first I have to check PnL position and then write if PnL> “target” exit AND if PnL<stop loss exit