I was using this formula :
PnL = (sellValue-buyValue)+(netQuantity x LTP x multiplier)
Note: getting LTP from websockets.
I dont know how it works but it works. I took it from another developer forum.
But this formula does not work when we have a delivery position of previous day.
case 1: when all the positions were taken today only.
case 2: when there exist some positions that were taken yesterday as delivery orders.
Can you please help me with the correct formula for the second case? If there is a better one for the first case, help me with that as well.