Incorrect data in history API

When calling the history data API for NSE symbol with instrument_token = 4274177, exchange_token = 16696, tradingsymbol = "GHCLTEXTIL" at 9:18am I got the 9:15am open value as 95.0. When calling the history API at 10:30PM, I'm getting a different open value - 94.7. Can you please check if there's a code bug? Open can not logically not change after the bar has started.

9:18 data returned for 9:15am Feb 7 2024 candle -
open = 95.0
close = 95.3
low = 95.0
high = 96.4
volume = 32690.0
ts = "2024-02-07 09:15:00.0"

same api call at 10:30pm returned -
open = 94.7
high = 96.4
low = 94.7
close = 95.3
volume = 32690
timeStamp = "2024-02-07T09:15:00+0530"
  • trd1
    trd1 edited February 8
    Here's another example for AVALON where close has changed between two API invocations. Volume does not change, so no additional ticks were received.

    Yesterday response -
    open=472.3, close=472.5, low=472.2, high=472.75, volume=1093.0, oi=0.0, symbol=AVALON, instrument_id=4053, ts=2024-02-07 15:23:00.0

    Today morning -
    o=472.3, c=472.75, h=472.75, l=472.2, v=1093, ts=2024-02-07T15:23:00+0530
  • trd1
    @sujith @rakeshr would it be possible to have someone look into this please?
  • trd1
    @Kailash @nitin could you please have someone in engineering acknowledge seeing this bug report?

    Apart from the history API, I use the RT streaming API. It's been working wonderfully for me. I understand these API subscriptions even at 48K/year don't bring in meaningful revenue to warrant actual support systems. Thanks for all the hard work on the Kite API suite. Please continue to keep these APIs available for individual folks.
  • trd1
    Any idea why these prices keep changing?
  • MAG
    Any idea why these prices keep changing?
    Are you getting the current days live data?
  • trd1
    Yes @MAG I keep refreshing the current day's data trailing by 10 mins.

    Key challenge is if a past candle changes, it could be due to corporate action or due to history data adjusting for late candles/processing. So we need to reload all candles which is expensive. For now, I'm using a 1% buffer assuming corporate actions wont change price by less than 1%.
  • rakeshr
    We run an open price update process around 09:20. The open price is determined during the pre-market period, which spans from 09:07 to 09:08. The last traded price (LTP) received at the regular market open, i.e., 09:15, may not necessarily align with the actual open price used for forming candles. Hence, we need to run this open insert process at 09:20 to ensure that the open field is correctly updated for the market open minute candle.
  • trd1
    Thanks for the info @rakeshr I'll acount for the open price changing now.

    Why did the 2024-02-07 15:23:00 close price for AVALON change? I'm trying to understand when price change is limited to past say 10 mins and when its due to corporate actions requiring a full reload for the symbol.
  • rakeshr
    Why did the 2024-02-07 15:23:00 close price for AVALON change?
    No, it won't change until you are requesting after the candle period is closed.
  • trd1
    Past candle close seems to be changing @rakeshr Could you please confirm why this happens or if its a bug?

    See one more example apart from AVALON below -
    Local DB for 5 min intervals was caught up till 3.15pm Feb 20 '24 -
    • open=823.8, close=832.9, low=823.8, high=832.9, volume=8741.0, oi=0.0, symbol=RATEGAIN, instrument_id=2495, ts=2024-02-20 15:05:00.0
    • open=831.35, close=821.75, low=821.45, high=832.4, volume=9861.0, oi=0.0, symbol=RATEGAIN, instrument_id=2495, ts=2024-02-20 15:10:00.0
    • open=821.75, close=818.35, low=815.4, high=822.1, volume=15648.0, oi=0.0, symbol=RATEGAIN, instrument_id=2495, ts=2024-02-20 15:15:00.0
    Kite history API call at 8AM on next day (Feb 21 '24) returned different close for 15:05PM candle.
    • o=823.8, c=831.75, h=832.9, l=823.8, v=8741, ts=2024-02-20T15:05:00+0530
    • o=831.35, c=821.75, h=832.4, l=821.45, v=9861, ts=2024-02-20T15:10:00+0530
    • o=821.75, c=818.35, h=822.1, l=815.4, v=15648, ts=2024-02-20T15:15:00+0530
  • MAG
    MAG edited February 21
    This should answer your query.
    A somewhat similar logic applies to open price too which is why many users complain that the open price has changed from what they see in the first tick at 9:15:00

    if you want to know more do a web search for "nse close price computation"
  • trd1
    Thanks for sharing this @MAG

    Is the 3.05pm candle close recomputed based on the average price or only the 3.30pm candle? In the example above, 3.05pm candle has changed. If we need to consider averaging for all candles after 3pm, I'll add that to the logic on my side.
  • MAG
    Absolutely no idea about the 3:05 candle. But then its the 'historical' data api. Its not supposed to be used for current day data and esp for any live trading.
    Again as said earlier, I am not a member of the zerodha team. I am a long term user of the api who is just trying to contribute back to the community. I have never faced any such issues since I have never used the historical api for getting current days data. I use the ticker api to get the ticks and process the candles.

    In fact; if I had been part of the zerodha team; I would have fought tooth and nail to have the historical api disabled for current day. That way there would be no way people could try using the historical api for live trading and half the forum queries/complaints would have disappeared.
  • trd1
    @MAG sounds like averaging is not the reason then. Lets please not conflate data discrepancy and end use. I'm not looking at using history API for live trading

    @rakeshr please take a look when you get the chance
  • MAG
    @trd1 Ok.
    Have you tried getting the tickdata, generating candles from that data and then comparing how it fares.
    Or candles from other sources like tradingview or kite web or Investar?
Sign In or Register to comment.