I’m trying to fetch the live 1-minute candles for the SENSEX index. To avoid partial data, I’m introducing a delay of about 5 seconds—for example, fetching the 09:15 candle at 09:16:05.
However, I’m still seeing data mismatches when comparing:
Live historical data (fetched with delay) vs End-of-Day (EOD) 1-minute candles
1. How much delay is actually required to reliably fetch accurate 1-minute candles? 2. Is there any guarantee that the candle is finalized within a specific time after the minute closes?
I also tried generating 1-minute candles using WebSocket ticks, but the results are worse:
. Highs and lows are not captured accurately . Candles differ significantly from EOD data
It is not guaranteed that a minute candle will be available at the end of the minute or at the beginning of the next minute. The historical data API is only for backtesting purposes.
The way the historical data service works is that it captures all the ticks in a minute and then generates a candle from them. The new candle is written to the database. This happens for all the instruments that are being traded for the day. There can be a delay since write operation to the database itself is uncertain. If one of the writes delayed then the following writes will also be delayed.
I would suggest generating candle at your end using the live market data provided by Kite Ticker. You may refer to the similar discussion here.
Today I observed that the historical 1-minute candle updates to accurate data only about 30 seconds after the close time. This aligns with @amitjet observation in this thread thread .
This level of latency is quite significant. Is there any way this can be improved? You’ve suggested generating candles using WebSocket tick data, but in my experience this approach is unreliable. The candles generated this way are often inconsistent with candle High is always less than actual EOD candle high and low is always higher than the EOD high. Essentially, the candle range gets compressed. As a result, indicators that depend on accurate OHLC data, such as SuperTrend, do not function correctly.
I hope the Zerodha backend team can look into this and reduce the latency to under 5 seconds instead of the current 30 seconds. While high frequency traders operate at sub-microsecond latencies, retail users dealing with these kind of delays are at a clear disadvantage.
Even if the historical API is primarily intended for backtesting, it would be helpful if zerodha can provide live and accurate candle data with minimum latency ( < 5 sec ) so that retail traders can efficiently perform live execution that is in Sync with the backtesting. @salim_chisty@sujith
The way the historical data service works is that it captures all the ticks in a minute and then generates a candle from them. The new candle is written to the database. This happens for all the instruments that are being traded for the day. There can be a delay since write operation to the database itself is uncertain. If one of the writes delayed then the following writes will also be delayed.
I would suggest generating candle at your end using the live market data provided by Kite Ticker. You may refer to the similar discussion here.
This level of latency is quite significant. Is there any way this can be improved?
You’ve suggested generating candles using WebSocket tick data, but in my experience this approach is unreliable. The candles generated this way are often inconsistent with candle High is always less than actual EOD candle high and low is always higher than the EOD high. Essentially, the candle range gets compressed. As a result, indicators that depend on accurate OHLC data, such as SuperTrend, do not function correctly.
I hope the Zerodha backend team can look into this and reduce the latency to under 5 seconds instead of the current 30 seconds. While high frequency traders operate at sub-microsecond latencies, retail users dealing with these kind of delays are at a clear disadvantage.
Even if the historical API is primarily intended for backtesting, it would be helpful if zerodha can provide live and accurate candle data with minimum latency ( < 5 sec ) so that retail traders can efficiently perform live execution that is in Sync with the backtesting. @salim_chisty @sujith