I am encountering an issue with the historical data API in live market conditions. Here's my use case:
1. I need to fetch the latest close values for a given Option with a 3-minute time interval. Based on these values, I calculate technical indicators such as RSI. 2. I am using the Kite Python client for this purpose. 3. I use the kite.historical_data method to fetch the data. 4. Every 3 minutes, I invoke this function to retrieve the most recent data and perform my calculations. 5. I set the to_date parameter as today's market close time, and the from_date parameter as 9:30 AM three weekdays before today.
The issue I am facing is that the RSI values I calculate, based on the data returned by the API, do not match the values shown on the Kite dashboard, particularly for the most recent intervals.
Upon investigation, I discovered that the `close` values fetched via the `historical_data` method appear to be incorrect for the latest data points. To confirm this, I have logged the latest 20 data points, including fetch timestamps, to a CSV file. By comparing these values to the ones displayed on the Kite dashboard, I can clearly see discrepancies in the "close" values for the same specific interval.
Interestingly, these values seem to be corrected after some time, usually around 30 minutes or so. However, I’ve observed varying behavior: sometimes the correction happens after just 2 minutes, while other times the values remain incorrect for much longer, even after 30 minutes.
For example, the "close" values for "18 Oct 2024 9:36 AM" for an instrument, fetched at 9:37 AM, 9:40 AM, 9:43 AM, and so on are different compared to the Kite dashboard. The most recent ones, say the 9:36 AM interval value fetched at 9:37 AM and 9:40 AM are incorrect. Most likely the are getting corrected in later fetches, say 10:00 AM.
My questions: 1. Is this a known issue with the `kite.historical_data` method when fetching live market data? 2. If so, how can I retrieve the correct, most recent values for my strategy, especially candle data for 3 minute interval? 3. I rely on accurate and up-to-date candle values for my strategy, and any delay in correcting the data causes inconsistencies in my calculations.
Any assistance or guidance on how to address this issue would be greatly appreciated.
The historical data API is only meant for backesting purposes only. We suggest generating candles at your end for live market strategies. You may get started from here.
You may get started from here.