Kite API Data discrepancy

amitjet
I am writing about a strange behavior seen in using the APIs for my trade program.

scenario: i am scanning values of an Option strike price every second and writing it in a log file for debugging purpose. (using historical apis)
every minute, i lookup historical api and pull out minute ohlc candle data for the strike price.
at day end, I download a full day data with minute candlesize from historical api to co-relate my calculations.

What i am seeing is a discrepancy in the data at all 3 levels.

BANKNIFTY2470352500PE

every second that i query historical api. i got following data
2024-07-01 11:53:55.401828,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:53:56.427824,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:53:57.453026,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:53:58.475000,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:53:59.500607,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:54:00.528390,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 280.75, 'low': 269.65, 'close': 280.75, 'volume': 111330}]
2024-07-01 11:54:01.554671,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 286.2, 'low': 269.65, 'close': 283.8, 'volume': 163620}]
2024-07-01 11:54:02.586770,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 286.2, 'low': 269.65, 'close': 283.8, 'volume': 163620}]
2024-07-01 11:54:03.620273,2024-07-01 11:53:00,[{'date': datetime.datetime(2024, 7, 1, 11, 53, tzinfo=tzoffset(None, 19800)), 'open': 272.8, 'high': 286.2, 'low': 269.65, 'close': 283.8, 'volume': 163620}]

every minute that i query historical api. i got following data
11:53:03: strike=BANKNIFTY2470352500PE OHLC=274.00,276.55,272.05,272.05
11:54:02: strike=BANKNIFTY2470352500PE OHLC=271.95,286.20,269.65,283.80

and at end of day:
2024-07-01 11:53:00+05:30 272.8,286.2,269.65,284.2,172905
2024-07-01 11:54:00+05:30,284.2,292,284.2,286.3,273840

as you can see. OHLC values are not consistent within Zerodha's same API used at different intervals.
  • sujith
    The historical data API is provided only for backtesting purposes. We don't recommend polling that for live market strategies. We suggest generating candles at your end using the live market data on Weboscket API.
    You can get started here.
  • mb12
    But even live data does not generate accurate candles i.e. if we generate minute data using websocket live data, and then compare it with historical minute data at EOD, it will not match. Is there a reliable way to generate candle data reliably during live market?
  • amitjet
    @mb12 has correctly put it up. I need a way to ensure that my minute candle data matches your historical minute data.

    I'll take it one level further. I have added an indicator Connors RSI on a chart twice. just to get two different bars/colors as per my needs. I see those 2 with exact same values on same chart simultaneously give 2 different values.

    There is something wrong in the way data is sent to apps via APIs. or it's just not reliable. hence defeating our purpose of programmatically accessing it.
Sign In or Register to comment.