Hi team, I was exploring your API V2 and have faced some issues, hope your attention in resolving the same. My concerns are mostly related to the get Positions API call. The data.average_price (Average price at which the net position quantity was acquired) property of any position is not getting updated, it remains 0 always. Here are the objects from 2 different instances.
When the netQuantity is 15 : {
“exchange”: “NFO”,
“multiplier”: 1.0,
“value”: 72.00009,
“pnl”: 7.8,
“product”: “D”,
“instrument_token”: “NSE_FO|43606”,
“average_price”: 0.0,
“buy_value”: 948.0,
“overnight_quantity”: 0,
“day_buy_value”: 948.0,
“day_buy_price”: 9.03,
“overnight_buy_amount”: 0.0,
“overnight_buy_quantity”: 0,
“day_buy_quantity”: 105,
“day_sell_value”: 876.0,
“day_sell_price”: 9.73,
“overnight_sell_amount”: 0.0,
“overnight_sell_quantity”: 0,
“day_sell_quantity”: 90,
“quantity”: 15,
“last_price”: 5.35,
“unrealised”: -55.2,
“realised”: 63.0,
“sell_value”: 876.0,
“tradingsymbol”: “BANKNIFTY2450847000PE”,
“trading_symbol”: “BANKNIFTY2450847000PE”,
“close_price”: 7.5,
“buy_price”: 9.028571,
“sell_price”: 9.733334
},
and when net Quantity was 0 : {
“exchange”: “NFO”,
“multiplier”: 1.0,
“value”: 0.0,
“pnl”: 5.25,
“product”: “D”,
“instrument_token”: “NSE_FO|43606”,
“average_price”: 0.0,
“buy_value”: 948.0,
“overnight_quantity”: 0,
“day_buy_value”: 948.0,
“day_buy_price”: 9.03,
“overnight_buy_amount”: 0.0,
“overnight_buy_quantity”: 0,
“day_buy_quantity”: 105,
“day_sell_value”: 953.25,
“day_sell_price”: 9.08,
“overnight_sell_amount”: 0.0,
“overnight_sell_quantity”: 0,
“day_sell_quantity”: 105,
“quantity”: 0,
“last_price”: 5.2,
“unrealised”: 0.0,
“realised”: 5.25,
“sell_value”: 953.25,
“tradingsymbol”: “BANKNIFTY2450847000PE”,
“trading_symbol”: “BANKNIFTY2450847000PE”,
“close_price”: 7.5,
“buy_price”: 9.028571,
“sell_price”: 9.078571
},
Secondly there is discrepancy while calculating the realised pnl in the positions. I bought a lot of BANKNIFTY2450847000PE at price 5.45 the prior realised pnl was 9.75 and I sold it at 5.15. so the final pnl ought to be 5.25 which is correct as seen in the second json, but when the position was active and the quantity is 15 the value is ”unrealised": -55.2, “realised”: 63.0, which do not make sense. Can you please mention how to calculate the live pnl using the price ticks from websocket, which is pal = realised Pnl + (last price - net average price)* net quantity for other brokers.
Also, I am unable to see lotSize and freeze Quantity field in each position, which is needed and often helpful for calculating the counter order size for closing the positions, these fields in position are considered standard and practice by most brokers.
Hope for the earliest resolution of the following queries.
Thanks.