Incorrect data from kite.positions API

mlearner
mlearner edited June 4 in Python client
I had overnight positions in few option strikes. Closed them today and took some fresh intraday positions in same strikes and some new strikes.
....
....
positions_list = kite.positions()
day_positions = positions_list['day']
print (day_positions)
....
....
1) When I try to iterate over "day_positions" to fetch currently opened positions, I am getting position quantity as non 0 for overnight strikes that I have already closed today.
2) In addition, the strikes that I again took intraday positions today & are currently open are also showing incorrect quantity data. This issue did not occur earlier when I had not taken any overnight positions.

My understanding is 'quantity' attribute in below JSON response should show up as 0 if no open positions exist against the respective product type MIS/NRML.

[{'tradingsymbol': 'NIFTY2161015500PE', 'exchange': 'NFO', 'instrument_token': 12234242, 'product': 'MIS', 'quantity': -450, 'overnight_quantity': 0, 'multiplier': 1, 'average_price': 48.52083333333333, 'close_price': 48.8, 'last_price': 40.25, 'value': 22106.24999999999, 'pnl': 3993.749999999989, 'm2m': 3993.749999999989, 'unrealised': 3993.749999999989, 'realised': 0, 'buy_quantity': 450, 'buy_price': 47.91666666666667, 'buy_value': 21562.500000000004, 'buy_m2m': 21562.500000000004, 'sell_quantity': 900, 'sell_price': 48.52083333333333, 'sell_value': 43668.74999999999, 'sell_m2m': 43668.74999999999, 'day_buy_quantity': 450, 'day_buy_price': 47.91666666666667, 'day_buy_value': 21562.500000000004, 'day_sell_quantity': 900, 'day_sell_price': 48.52083333333333, 'day_sell_value': 43668.74999999999}, {'tradingsymbol': 'NIFTY2161015600PE', 'exchange': 'NFO', 'instrument_token': 12235266, 'product': 'MIS', 'quantity': 450, 'overnight_quantity': 0, 'multiplier': 1, 'average_price': 77.86666666666666, 'close_price': 77.05, 'last_price': 66.15, 'value': -35647.5, 'pnl': -5879.999999999996, 'm2m': -5879.999999999996, 'unrealised': -5879.999999999996, 'realised': 0, 'buy_quantity': 900, 'buy_price': 77.86666666666666, 'buy_value': 70080, 'buy_m2m': 70080, 'sell_quantity': 450, 'sell_price': 76.51666666666667, 'sell_value': 34432.5, 'sell_m2m': 34432.5, 'day_buy_quantity': 900, 'day_buy_price': 77.86666666666667, 'day_buy_value': 70080, 'day_sell_quantity': 450, 'day_sell_price': 76.51666666666667, 'day_sell_value': 34432.5}]

-How can I know my open positions with right quantity value?
-Is there some intermittent issue with kite.positions() API?

Kindly reply soon as this discrepancy is breaking multiple things.
  • sujith
    You should be checking net positions if you are having overnight positions.
    Can you private message the client id?
  • mlearner
    Hey Sujith,

    I checked 'net' positions. It is correctly showing quantity values for only my open positions.

    I am wondering what is 'day' positions data for then? It is still showing very random values for quantity. I have been using 'day' positions only until I faced this issue today.

    If we have to check currently opened positions(MIS or NRML), should we always use 'net' positions and check for positions that have quantity value as non 0?

    Please clarify.

    Thanks.
  • rakeshr
    If we have to check currently opened positions(MIS or NRML), should we always use 'net' positions and check for positions that have quantity value as non 0?
    Yes, you should always use net positions and check for non zero Qty. You can also go through this similar thread, which explains regarding day and overnight Qty.
  • mlearner
    Understood the thread @rakeshr. Will check net positions only.

    But I could not understand why my day positions are showing non 0 value for quantity even though I do not have any open positions(MIS or NRML) for those strikes.

    Also I missed mentioning that I had converted all my NRML positions to MIS today morning. But since they are all closed now, my day positions should also show 0 for quantity.

    For instance, below 'day' position is a converted one from NRML to MIS. But since my position is currently closed, quantity should have appeared as 0. Whereas it's showing "-450" (SELL), which is not even right and opposite of the position I had taken. I think there is some bug here.

    [{'tradingsymbol': 'NIFTY2161015500PE', 'exchange': 'NFO', 'instrument_token': 12234242, 'product': 'MIS', 'quantity': -450, 'overnight_quantity': 0, 'multiplier': 1, 'average_price': 48.52083333333333, 'close_price': 48.8, 'last_price': 45.2, 'value': 22106.24999999999, 'pnl': 1766.249999999989, 'm2m': 1766.249999999989, 'unrealised': 1766.249999999989, 'realised': 0, 'buy_quantity': 450, 'buy_price': 47.91666666666667, 'buy_value': 21562.500000000004, 'buy_m2m': 21562.500000000004, 'sell_quantity': 900, 'sell_price': 48.52083333333333, 'sell_value': 43668.74999999999, 'sell_m2m': 43668.74999999999, 'day_buy_quantity': 450, 'day_buy_price': 47.91666666666667, 'day_buy_value': 21562.500000000004, 'day_sell_quantity': 900, 'day_sell_price': 48.52083333333333, 'day_sell_value': 43668.74999999999}]
    Thanks.
  • sujith
    The basic concept is day positions only show today's activity.
    It is a concept from NEST, a little complicated. To keep it simple we show only net positions on Kite mobile app but the Kite web shows both but the net positions take precedence.
    We would suggest you use net positions only.
  • mlearner
    @sujith - Got it. Thanks.
This discussion has been closed.