P&L formula

shailu
In thread - https://kite.trade/forum/discussion/3166/getposition-is-not-having-updated-value
It has been suggested to use this formula to get Pnl -
pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
It will be great, if you pls elaborate the attributes here.

  • Vivek
    Vivek edited February 2018
    You will get all these values in positions response itself. For example
    "net": [{
    "tradingsymbol": "NIFTY15DEC9500CE",
    "exchange": "NFO",
    "instrument_token": 41453,
    "product": "NRML",

    "quantity": -100,
    "overnight_quantity": -100,
    "multiplier": 1,

    "average_price": 3.475,
    "close_price": 0.75,
    "last_price": 0.75,
    "value": 75.0,
    "pnl": 272.5,
    "m2m": 0.0,
    "unrealised": 0.0,
    "realised": 0.0,

    "buy_quantity": 0,
    "buy_price": 0,
    "buy_value": 0.0,
    "buy_m2m": 0.0,

    "day_buy_quantity": 0,
    "day_buy_price": 0,
    "day_buy_value": 0.0,

    "day_sell_quantity": 0,
    "day_sell_price": 0,
    "day_sell_value": 0.0,

    "sell_quantity": 100,
    "sell_price": 3.475,
    "sell_value": 347.5,
    "sell_m2m": 75.0
    }]
    So the formula is

    pnl = (position.sell_value - position.buy_value) + (position.quantity * lastPrice * position.multiplier)

    You should be using last price you get from ticker to calculate live positions pnl. This exactly the same thing going on Kite web and Kite apps.
This discussion has been closed.