Exit Position - By Id not working? Details here... https://community.fyers.in/post/exit-position---by-id-not-working-60d98e65b90dbc384b029321

Exit Position - By Id not working? Details here… Exit Position - By Id not working.

Hi Team,

I tried calling this endpoint and it returned following response.

{
“s”: “error”,
“code”: 500,
“message”: “Looks like you are passing an invalid entry”
}

payload was…

{
“symbol”: “NSE:BANKNIFTY2170135400PE”
}

HttpVerb: Delete
Endpoint URL: https://api.fyers.in/api/v2/positions

I can confirm that I used this symbol to place order and it worked but existing the postion with same symbol resulted in error.

Please assist.

Thank you,

Algo Trader

Hi Algo Trader, 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 link