Dear v2 API Team
I want to bring to your attention that the previous candles data in intraday history API is being updated after 8-10 seconds of new/next minute.
e.g. At 09:30:00 hours the data for 09:29:00 minute comes at least after 09:30:08 to 09:30:10. I have attached the screenshot of my logs for your reference.
This is consistent since the day I started using the APIs. Please do share if this is intended or the duration could be reduced further.
Thank you for contacting us and sharing your observation.
We suggest utilizing real-time WebSocket to access the most recent two candles in the intraday timeframe. Specifically, for 1-minute and 30-minute intervals, we provide two candles, which include the current one and the previous one.
Regarding the delay in the cache response, we have implemented caching for the intraday REST API to improve performance. Currently, we are examining the possibility of optimizing the current Time To Live (TTL) for the cache.
Yes, I also feel websockets are the way to go for real time data. I am repeating the queries here which I asked in the other thread which got drowned in the digression about Uplink video record.
The thing is web sockets are very tricky to implement and has got me bogged down completely. Please help with the following:
Can we get stream for multiple instruments? Tried passing Nifty 50 and Bank Nifty was getting data for only one of the two.
Should the instruments be of same segment? I tried Nifty Bank and one of the options.Got data for Nifty Bank only.
What is the ideal Upstox way to go about Websockets? Get one wss:// url and keep using the same connection throughout while sending sub, unsub when we want to change instruments. Or generate a wss:// authorized url for each each instrument and keep using until needed.
I would appreciate the inputs.
Thanks in advance.
It is advisable to utilize a single web socket and employ subscription (sub) and unsubscription (unsub) methods for handling multiple instruments.
Our web socket has been specifically designed to receive concurrent streams for various instruments across different segments. It’s important to note that the key of the instrument is an array, such as:
instrumentKeys: ["NSE_INDEX|Nifty Bank", "NSE_INDEX|Nifty 50"]
If you can upload your code to GitHub and provide us with the link, we would be able to assist you more effectively. By sharing your code, we can offer prompt guidance for integrating the web socket. We intend to release the implementation code for the web socket on GitHub to facilitate early adoption and integration.
I have all the info now. Asking for anything more is like asking you to write the code for me now
I will try to share the code and get help once I am ready to deploy after replacing the typical history apis with websocket.
I had not expected such prompt response everytime.
We are happy to hear that.
Thank you for your support