MTM calclation

I understand other parameter....Whats multiplier parameter here???

pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
  • rakeshr
    Are you calculating P&L for F&O contracts?
    If yes, then the multiplier here is the lot size of a specific contract.
  • XS8910
    i got it...thanks a lot
  • AnandMC
    I used this code pnl = (position['sell_value'] - position['buy_value']) + (position['quantity'] * position['last_price'] * position['multiplier'])
    Even then since yesterday pnl is showing wrong information.

    There is nothing called net_quantity.

    Can you please help
  • sujith
    You need to use quantity field.
  • sujith
    And you can't use the position response's last price, you need to use Websocket API or quote API to get the last traded price.
  • AnandMC
    position['pnl'] was working until OCT11. Fine. I'm using the below python code now

    for position in positions :
    pnl = (position['sell_value'] - position['buy_value']) + (position['quantity'] * position['last_price'] * position['multiplier'])
    sum = sum + position['pnl']

    Can you let me know how to use "Websocket API or quote API" in python to get last price
  • sujith
    You may refer to the readme and documentation here.
  • AnandMC
    Have used the below code as you mentioned. However even now there is a change pnl of what is show in the kite web and what is shown in the code. Every thing was working fine until OCT 11.

    exit = 0
    while exit == 0:
    positions = kite.positions()
    positions = positions['net']
    sum = 0
    print('positions is')
    for position in positions :
    print("quote is")
    ins = 'NFO:' + position['tradingsymbol']
    lp = kite.quote(ins)[ins]['last_price']
    pnl = (position['sell_value'] - position['buy_value']) + (position['quantity'] * lp * position['multiplier'])
    print('pnl is')
    sum = sum + position['pnl']
    print("Total BANK Nifty P & L")
  • AnandMC
    sorry have used sum = sum + position['pnl'] instead of pnl. It works thanks
This discussion has been closed.