Incorrect OHLC Candle Data at different times

madhumattangi
I am receiving different OHLC data (close and volume) when queried immediately after the candle and after 2 minutes. Here is the log trace of my program. Should I use a different API for the accurate last 3 candles?

Appreciate your help. Apologies if its a repeat qn.


fetchOHLC_last_N_Candles:: Latest Candles..
date open high low close volume
0 2022-06-01 13:00:00+05:30 1063.50 1063.55 1058.0 1058.05 9455
1 2022-06-01 13:15:00+05:30 1058.05 1059.90 1055.3 1058.25 14102
2 2022-06-01 13:30:00+05:30 1058.25 1059.00 1058.0 1059.00 44
System Date: 2022-06-01 13:30:45.749954 Candle Datetime: 2022-06-01 13:30:00+05:30 close: 1059.0

fetchOHLC_last_N_Candles:: Latest Candles..
date open high low close volume
0 2022-06-01 13:15:00+05:30 1058.05 1059.90 1055.3 1058.25 14102
1 2022-06-01 13:30:00+05:30 1058.25 1061.50 1057.0 1057.45 6033
2 2022-06-01 13:45:00+05:30 1057.45 1057.55 1057.0 1057.55 115
System Date: 2022-06-01 13:45:45.799105 Candle Datetime: 2022-06-01 13:45:00+05:30 close: 1057.55

fetchOHLC_last_N_Candles:: Latest Candles..
date open high low close volume
0 2022-06-01 13:30:00+05:30 1058.25 1061.50 1057.0 1057.45 6033
1 2022-06-01 13:45:00+05:30 1057.45 1059.85 1056.0 1058.80 4467
2 2022-06-01 14:00:00+05:30 1058.80 1059.80 1058.8 1059.00 190
System Date: 2022-06-01 14:00:45.883868 Candle Datetime: 2022-06-01 14:00:00+05:30 close: 1059.0


  • SRIJAN
    SRIJAN edited June 2022
    KiteConnect gives the data for the current live candle too, alongwith the completed candles.

    So, let's say when you fetched historical data at 14:00:45,it fetched all the completed candles,plus the candle which started at 14:00:00 ,for which HLCV will keep changing till the candle closes i.e 14:14:59.

    Hence,when you fetched data at 13:30:45 ,it had the data for the candle started at 13:30:00,which was still live,and so the HLCV kept changing till 13:44:59.
    When you fetched data at 13:45:45,the 13:30 candle was completed,so,the HLCV changed which are fixed now ,but you can see that open has not changed from the previous response fetched at 13:30:45 ,as open is fixed when the candle starts.
  • madhumattangi
    It means I should wait until the candle completes before fetching it.

    Thanks, Srijan. Appreciate it.
This discussion has been closed.