Understanding PNL

prakash.jj
Hi,

I am little confused on the way the Kite Positions methods gives the result.

For Example;
Lets say, I took a trade on Scrip XYZ and made 100 Rs loss and closed it.
I again take a trade in the same Scrip XYZ and the current trade is making 20 Rs loss lets say.
I thought when I look at the output of Kite.Position method, realised should be 100 and unrealised = -20 and pnl = 80... But that I dont think thats how the api is working. Can you please confirm the difference between realised, unrealised and pnl values. @sujith @Kailash @Vivek

Cheers
Prakash
  • prakash.jj
    Guys this is really frustrating....why can't anyone answer on how it is supposed to work. @Kailash @sujith @Vivek
  • sujith
    Hi,
    Since order history is not known in positions and the live price is not known in Positions API. We don't use realised and unrealised fields. Instead, you can use pnl field which is a sum of realised and unrealised.
    We may discontinue these fields in future.
  • prakash.jj
    Awesome....how do I know the profit or loss on the current open position in real-time then? Are you saying we can't use positions API for that and instead should try to build our own mechanism to calculate based on order history and latest price?
  • sujith
    You can use this formula,
    PNL = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
  • prakash.jj
    thank you. I will try this and give my feedback
This discussion has been closed.