Live MTM update using python script

XS8910
am using python script to exit all position if my MTM SL limit exceeded for the day.
every 60 seconds am pulling the data via "get_positions()" , but its not having updated value....seems like whenever i pull the data its having 5 mins old data....please help.

*******************************************************************************************************************
Current Intraday Position
===============================================================================================================
tradingsymbol exchange product quantity last_price day_sell_price day_buy_price pnl day_sell_quantity day_buy_quantity
0 NIFTY20AUG11300CE NFO MIS -75 203.10 215.65 0 941.25 75 0
1 NIFTY20AUG11300PE NFO MIS -75 17.35 16.25 0 -82.50 75 0
2 NIFTY20AUG11350PE NFO MIS -75 24.40 22.90 0 -112.50 75 0
3 NIFTY20AUG11400CE NFO MIS -75 120.45 131.45 0 825.00 75 0
4 NIFTY20AUG11400PE NFO MIS -75 35.00 32.10 0 -217.50 75 0
5 NIFTY20AUG11500CE NFO MIS -75 57.00 63.90 0 517.50 75 0
6 NIFTY20AUG11500PE NFO MIS -75 71.40 64.45 0 -521.25 75 0
7 NIFTY20AUG11600CE NFO MIS -75 19.45 22.50 0 228.75 75 0
-------------------------------------------------------------------------------------------------------------------------
==================================================================================
Current MTM: 1578.75 Net QTY: -600.00 Current SL Limit: -4000.0
==================================================================================
  • sujith
    You can refer to this thread.
  • XS8910
    XS8910 edited August 2020
    yes...i tried this already..."last price" also updating every 5 mins only....not every 60 seconds.. only "quantitiy" getting updated correctly...
    pnl = (sellValue - buyValue) + (netQuantity * lastPrice * multiplier);
  • sujith
    You need to use Websocket API or Quote API to fetch live market data. We don't recommend polling positions for getting updated P&L value.
  • XS8910
    thanks i will try and update you thanks
  • XS8910
    fixed...thanks
This discussion has been closed.