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.
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.
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.
@AbhishekRathore
I used the same formula. It worked fine when all the positions were taken today only.
But it breaks if some positions were taken yesterday as delivery orders.
Please help.