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.
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.
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.
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?
@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.
You can get started here.
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.