How to calculate todays p &l and Overall p&l for upstox api

Hello,

I am trying to calculate todays P&l and overall P&L.

How to calculate that by reading get position API or any other method available to calculate that.

HI @Chaitanya_Kalyani,

You can use the below formula to calculate P&L accordingly
pnl = (buy_value - sell_value) + (quantity * multiplier * ltp)

Hello @AbhishekRathore

pnl = (buy_value - sell_value) + (quantity * multiplier * ltp)
is for total Pnl or total Pnl?

@Chaitanya_Kalyani - this would be the total Pnl for the particular position

Do note that there upto 1 minute of cache in get position API, so you might receive a slightly outdate pnl.
So you can use this formula to get real-time pnl by getting the real-time LTP from websockets.