Formula to calculate PNL & Avg price like in Kite positions page

mailboxofrafiq
Hi @sujith

1. I want to calculate PNL like in Kite positions page.. I was your post on this..
pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
what is multiplier here?

2. What is the formula to calculate Avg price provided there are multiple buy and sell order intraday on same instrument?
Tagged:
  • sujith
    sujith edited November 2023
    Multiplier, Average price, buy value and sell value are there in the positions response.
  • gautamsatpathy
    @sujith

    Average Price is available in Positions payload only for Open Positions, right? If the position is currently closed (buy quantity = sell quantity and quantity = 0) then the payload carries average_price = 0 as per documentation page sample JSON payloads.

  • themohammedfaisal
    @gautamsatpathy ,

    Yes, you are right. However, you should be able to compute the average using the day buy and sell values still part of the positions struct.
  • pranavshinde1000
    pranavshinde1000 edited December 2023
    Why you guys are not able to give the exact equation for PNL computation as per Positions page. I see various post with people are struggling for the same PNL calculation.
    Why cannot exact logic be give from Zerodha Side.

    Moreever, free API providers like Fyers are giving live PNL in the positions API.
    We are paying 2000 rs here, why this simple things cannot be taken seriously.

    Most of the traders will want to set an Exit/Close all positions if PNL crosses certain value (eg. - 5000) we also dont have Exit Positions API !
    You guyz are asking to place the reverse orders for each open position. What if we exit the order from terminal and at the same time our code also places the reverse order.

    These very simple and basic requirements needs to be understood by such a big broker.

    API team not working actively is what i feel.

    @ZerodhaAPI @sujith @ZerodhaAlgoTrading
  • MAG
    MAG edited December 2023
    All the data is available. I compute my own PNL for each trade I take, Plus PNL of open positions in real time.

    I am wondering if I am missing something and not understanding your query.
  • sujith
    This is the formula and everything is available in the API. Latest LTP is available on Quote API or Websocket API.
    pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
  • pgangwal
    @sujith Do you guys send PNL directly when the position is still open? Or do we have to always calculate it using the formula you mentioned above? And why you can not provide it directly?
  • sujith
    Kite Connect caches values. It doesn't compute every second. Front end apps needs to do it.
Sign In or Register to comment.