For monitoring purpose we use the kite.positions() API to check our PNL every 5 seconds. But the pnl field in the kite.positions's result is not same as the one we see in the kite.zerodha webpage's POSITIONS tab. One example was as below: Please note that the "pnl" and the "unrealised" was fixed at 1083.75 for a minute. For BANKNIFTY2321641600PE Symbol the kite.positions API returned as below every 5 seconds. {'tradingsymbol': 'BANKNIFTY2321641600PE', 'exchange': 'NFO', 'instrument_token': 11182594, 'product': 'NRML', 'quantity': -25, 'overnight_quantity': 0, 'multiplier': 1, 'average_price': 359.95, 'close_price': 0, 'last_price': 316.6, 'value': 8998.75, 'pnl': 1083.749999999999, 'm2m': 1083.749999999999, 'unrealised': 1083.749999999999, 'realised': 0, 'buy_quantity': 0, 'buy_price': 0, 'buy_value': 0, 'buy_m2m': 0, 'sell_quantity': 25, 'sell_price': 359.95, 'sell_value': 8998.75, 'sell_m2m': 8998.75, 'day_buy_quantity': 0, 'day_buy_price': 0, 'day_buy_value': 0, 'day_sell_quantity': 25, 'day_sell_price': 359.95, 'day_sell_value': 8998.75}
Whereas the actual PNL was 1300+. The live pnl in the positions tab was changing every second. How to ensure that the pnl and unrealised values of the kite.positions() API works. Or is this a bug?
pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);