I am not able to stream all the ticks continuously. After receiving the ticks once for all the instrument tokens, I am getting the below connection error. Can you please help me resolve this?
Connection error: 1006 - connection was closed uncleanly (None) Connection closed: 1006 - connection was closed uncleanly (None)
Please find the code below: def on_ticks(ws, ticks): output = pd.DataFrame() # Callback to receive ticks. for tick in ticks: a={key: tick[key] for key in tick.keys() & {'timestamp', 'instrument_token', 'last_price', 'volume'}} output = output.append(a, ignore_index=True) output.to_csv('data2.csv', index=False)
import csv from kiteconnect import KiteTicker import pandas as pd
filename = "access_token.csv" fields = [] rows = [] with open(filename, 'r') as csvfile: read = csv.reader(csvfile) fields = next(read) for row in read: rows.append(row)
# Initialise kws = KiteTicker(api_key, access_token) def on_connect(ws, response): rows = [] all_toks = [] filename="instruments1.csv" with open(filename, 'r') as csvfile: read = csv.reader(csvfile) for row in read: rows.append(row[0]) for i in range(1,len(rows)): all_toks.append(int(rows[i]))