How to get Latest pnl of all unrealised intraday trades

gawaskar21
Hi,
I want to exit from all trades if day loss exceeds some amount. For that i want to get the updated pnl value each 5 seconds.
I was retrieving Unrealised/PnL value from positions but its values are not dynamic. They are getting updated every 15 minutes.
Please help.

Code snippet.


q, err := kiteapi.GetPositions()
netpnl := 0.0
for i := range q.Day {
pnl := q.Day[i].Unrealised
netpnl += pnl
i++
}


Tagged:
  • rakeshr
    You can calculate P&L at your end using Websocket streaming. This thread explains more on this.
  • gawaskar21
    pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
    how can this give current pnl of day ?
  • sujith
    You need to fetch the last price from the Websockets API.
Sign In or Register to comment.