I need to determine closing price for 1 min candles , I tried using Historical API , but that was delayed 30+ seconds , so I tried using Websockets , but the data is mismatched a lot. This is for token 12106754, the closing price in the WebSocket was 71.15 but in the Historical API I got 70.55. (Screenshots are attached) So according to the websocket data on 13:57:59 LTP was 71.15 after which there was no tick data. But when I fetched through API it is 70.55. Why there is a difference ? How to get the correct closing price ?
I am building something in Realtime which needs closing price data, what should I do now?
Issues: 1. Historical API is 30 seconds delayed. 2. WebSocket data is not matching with OHLC data.
Requirement: I need closing price in Realtime for each min to for my indicators to work (they are dependent on closing price for each candle) Please give solution
Code: ``` # Callbacks def on_connect(ws, response): print("[✓] Connected to WebSocket") print(f"[INFO] Response: {response}") try: ws.subscribe(TRACK_TOKENS) ws.set_mode(ws.MODE_FULL, TRACK_TOKENS) print(f"[✓] Subscribed to tokens: {TRACK_TOKENS}") except Exception as e: print(f"[ERROR] Failed to subscribe: {e}") ``` This is my on_connect function , i am simply printing it on the console to check it in real time , i have attached screenshots for the proof 1 SS is for the Websocket data . and the other one is of the API .
It doesn't have to match exactly because both have different sources. If you need accurate tick-by-tick data, you need to be at the exchange in a colocation server, which costs 20+ lakhs per annum.
Please check out this thread for more information.
Then what's the use of websocket data if its not accurate ? how can someone use data which is incorrect ? I though the websocket data source would be Zerodha itself.
So ultimately you're saying that "I WON'T EVER BE ABLE TO FETCH REAL LIVE TICKS ? WITH ZERODHA "
@dardarsh, It is not only about Zerodha, it is about any platform out there that provide data over the internet. All the members consume only level 2 data and provide the same to their clients. Please go through the article, it explains why data is different on different platforms. Ultimately, one can only capture trend and not get the exact value.
PS: Kite Connect is not meant for HFT or latency based trading.
Please check out this thread for more information.
I though the websocket data source would be Zerodha itself.
So ultimately you're saying that "I WON'T EVER BE ABLE TO FETCH REAL LIVE TICKS ? WITH ZERODHA "
It is not only about Zerodha, it is about any platform out there that provide data over the internet. All the members consume only level 2 data and provide the same to their clients. Please go through the article, it explains why data is different on different platforms. Ultimately, one can only capture trend and not get the exact value.
PS: Kite Connect is not meant for HFT or latency based trading.