Skip to main content
Question
FYERS API
Asked a question 2 years ago

Hi, I am trying to exit only a particular position using data = { "symbol": symbol } print(fyers.exit_positions(data)) Ex: symbol = NSE:NIFTY2140815000CE( it was intraday position) But everytime, it is exiting all my positions. For testing, I bought 1 share of ITC(CNC) and tried exiting only ITC position but it exited all my position. fyers.exit_positions({"symbol":"NSE:ITC-EQ"}) any suggestion, what am I doing wrong?

Join FYERS Community to pick others' brains on Trading/Investing

Hi Akash, sorry for the trouble you faced and for the late reply.
Please note that we have migrated to api v2.
The key the user is using is incorrect. "id" here is an optional field, all the positions will be exited if it is not mentioned.
However user can close a specific position in this way by specifying the id.
data  = {
     "id":"NSE:SBIN-EQ-BO"
   }
fyers.exit_positions(data) 
In api v2 there is a option to exit position by id, for more detailed you can checkout this link95