How to calculate PnL real-time with delivery positions of previous day?

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.

@Pradeep_Jaiswar

Hi @Yadvendra_Sharma

What’s multiplier in the above equation? And are you sure its a “+” instead of “x”?

@MohitGolecha
the multiplier i am getting in positions
I don’t really know what it means
can you please help me in calculating pnl for both cases(as mentioned above)
[case 1: when all the positions were taken today only.
case 2: when there exist some positions that were taken yesterday as delivery orders.]

forget the above equation
tell me from scratch how do I do it
I get static positions from API and ltp from websocket live feed.