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 config 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
@FYERS please review...
Hello,
You should pass the Order ID as payload and not the symbol.
Hii @Pranav Shinde ,
I referred to API v2 documentation here... https://api-docs.fyers.in/v2/?language=CURL#exit-positions.
There is no mention of OrderID, the examples given also refers to symbol.
Also when I tried the exit postion by Id, it worked for me.
Hope this helps someone someday.
I had similar issue.
My case was
I'm using Position closing by Symbol.
The documented process says that closing particular position is possible if we mention the symbol
Why is it not working as expected? Its closing all the positions instead of the specified one.
data = { "symbol": "NSE:SBIN-EQ" } fyers.exit_positions(data)Eg: NSE:SBIN-EQ
Reply from Fyers support:
Thankyou for contacting FYERS.
Dear Sir
use the id field of the position. to Square off for the particular position you can use the position_id to square off
for reference attaching the docs link over here: https://api-docs.fyers.in/v2/?language=Python#exit-position---by-id
Instead of passing as symbol as parameter you needs to pass id for the position
Thank you @Ashish Kesarkar for your reply,
I changed my implementation to place counter order to exit current position as a workaround. Haven't had chance to test this though but I am confident that it will work.
warm regards,
Algo Trader.
Hey @algo trader ! Thanks for pointing this out to us.. We have made the necessary correction in the API Docs. Exit Position by Symbol is not supported right now. You can exit all or you can exit based on position_id.
We are also launching a new exit position functionality.. Stay tuned!
Hey @Yashas Khoday !
Can you please tell which position_id you are talking about. I did not find any position_id variable in documentation.
Is it order id generated while placing order?
Please confirm..!
Hey @Yashas Khoday : Its still not working
For order detail:
{'orderDateTime': '26-Aug-2021 14:01:21', 'id': '2210826219164', 'exchOrdId': '1000000065826966', 'side': -1, 'segment': 11, 'instrument': 14, 'productType': 'INTRADAY', 'status': 2, 'qty': 100, 'remainingQuantity': 0, 'filledQty': 100, 'limitPrice': 0.0, 'stopPrice': 0.0, 'type': 2, 'discloseQty': 0, 'dqQtyRem': 0, 'orderValidity': 'DAY', 'source': 'ITS', 'slNo': 2, 'fyToken': 'XXXX', 'offlineOrder': False, 'message': 'TRADE CONFIRMED', 'orderNumStatus': '2210826219164:2', 'tradedPrice': 12.8, 'exchange': 10, 'pan': 'xxxx', 'clientId': 'XXX', 'symbol': 'NSE:NIFTY21AUG16650CE', 'ch': -19.45, 'chp': -60.4, 'lp': 12.75, 'ex_sym': 'NIFTY', 'description': '21 Aug 26 16650 CE'}
res = fyers_v2.exit_positions(
data={'id': "2210826219164"}
)
Error response is {'s': 'error', 'code': -397, 'message': 'Please provide a valid position Id'}
I tried with different values for 'id': 1000000065826966 or "NSE:NIFTY21AUG16650CE" or "NSE:NIFTY21AUG16650CE-BO" etc but same error again and again
Very irritating and confusing.
Hi, Here the position ID can be found when you get positions using fyers.positions(). Normally its combination of the symbol and productType.
However now even exit by symbol is also working.