@sujith , hello hoping you would help trying to stream data from a web socket with the following code on_ticks(ws, ticks): for single_company in ticks: token = single_company['instrument_token'] time = single_company['timestamp'] temp[token][time] = single_company['last_price'] try: df = pd.DataFrame.from_dict(temp[token], orient='index') ohlc = df.resample('1Min').ohlc() df_one.loc[time.strftime("%d/%m/%y %H:%M")] = tuple(ohlc.iloc[-1]) df_one.sort_index(inplace=True) df_one.to_csv(os.path.join(path,f'{str(token)}.csv')) except Exception as e: logger.info(e)
I am getting a few points difference from the real value.
What is your source of comparison?
on_ticks(ws, ticks)
We see you are performing some computation inside the on_tick thread. That can be a reason for the delay. Maybe you can debug further on this on your end.
When you generate candles from Websockets, it won't match exactly but it will be near.
You can know the reason here.