Positions Output with Corrupt LastPrice

abhivin123 edited October 2022 in Python client
In python client, for the following json output -
positions = kite.positions()
jsonData = positions["net"]
for item in jsonData:
last_price = item.get("last_price")
is it possible that the attribute "last_price" in those positions have value 0.00 or some other corrupt data, even when the rest of the positions json output and structure are correct?

Going through the logs makes me feel that is the only possible explanation. I also manually got the last_price set to 0.00 in positions response and was able to reproduce the issue. Please note that I do have proper error checks and catchers in place, but in this peculiar case the structure was correct, output was fine but just the value in last_price incorrect. This has never happened before but have just seen it once last week and once today (around 3:16 PM). And today, unfortunately it resulted in my risk parameters triggering immediate exit of the whole portfolio.

I know a logged output of positions json data at that time would have helped narrow this down (and I have enabled it), but the issue is intermittent and rare if not for the past week or so. Anyhow, bottomline - is last_price data added to positions data in some kind of post processing at the api end and is it possible that last_price is corrupt but rest of the positions response is intact?
  • sujith
    This is very unlikely, can you log the response and give it next time this happens?
    The intermittent solution is to fetch last price from ticker or get quote when it happens.
Sign In or Register to comment.