Delay In Historical Data API
-
Hi @admin
I am currently trying to work on a logic that requires getting the candleData of ONE_MINUTE time-frame of Futures (NFO) in real time(i.e to get the 09:15, 09:16, 09:17 candleStick data as soon as the minute is completed). The response should have OHLC Volume data. I have two question
- I would like to know what are all the options available to get the the required data every one minute.
- I already tried hitting the Historical Data API with currentDays from and to Time Stamp. For example, Lets assume that today is Feb 3, 2023 and I tried to hit the historical data api at 09:16 with the below request which will produce the response that will have one array element which holds 09:15 candledata.
REQUEST FOR HISTORICAL API
{ "exchange": "NFO", "symboltoken": "48756", "interval": "ONE_MINUTE", "fromdate": "2023-02-03 09:15", "todate": "2023-02-03 09:15" }
Here, my second question is, when i hit the historical API every one minute ie 09:15:00. 09:16:00 and 09:17:00 .... so on, I am not getting the latest candle data in the response, it takes atleast ~5 seconds after a minute is completed to get the latest candledata in historical api. i.e I get the desired result at 09:15:05, 09:16:04 and 09:17:05 etc.... So , is there any way to reduce this 5sec gap in fetching the desired result or is there any other API that i can use instead of historical data API to get the candlestick data of one minute timeframe without any delay.
-
@falconTrader
Thanks for replying.Unfortunately, the websocket streaming method doesn't provide the option to request data based on specific time frames, such as ONE_MINUTE or FIVE_MINUTE. To obtain OHLC data like what's available from the Historical API, manual collection and calculation of data from websocket streaming would be required. This can be a time-consuming process and may result in some delay, even if processing time is only in the range of milliseconds to seconds, It will have a huge impact during high volatility market days.
Also, I use Java and my bad i couldnt help you with ur python issue. 😢
-
@laskshmi, I believe the 5 seconds delay is inherent and AFAIK also mentioned somewhere in the API documentation as well.
As far as I am aware, brokers generally have 2 servers, one for real time quote and other for historical data.
To tackle your problem, the solution seems to be websocket streaming.
So far I have been un-able to resolve my SMARTAPI code with websocket streaming but I believe that is the solution for quick candle update.
The Python SDK documentation is in-adequate to help members demonstrate websocket usage !