def on_tick(tick, ws): print("Sudheer") print(type(tick[0])) print(len(tick[0])) #print(pd.Panel(tick[0])['ohlc']) for x, y in tick[0].items(): print("Key - Value ", x, y)
def on_connect(ws): # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). ws.subscribe([5633])
# Set RELIANCE to tick in `full` mode. #self.kws.set_mode(ws.MODE_FULL, [5633])
# Callback for tick reception. def on_tick(tick, ws): print("Sudheer") print(type(tick[0])) print(len(tick[0])) #print(pd.Panel(tick[0])['ohlc']) for x, y in tick[0].items(): print("Key - Value ", x, y)
I am not sure what's wrong here. If the sample code is working fine and your class based code isn't, there's an issue with the class implementation at your end.
do we need to handle the callback kind of thing in special way ..while using in class?
public_token = "xxxxxx"
api_key="xxxx"
user_id = "xxx"
#--------------------------------------------------#
# Initialise.
kws = WebSocket(api_key, public_token, user_id)
# Callback for tick reception.
def on_tick(tick, ws):
print("Sudheer")
print(type(tick[0]))
print(len(tick[0]))
#print(pd.Panel(tick[0])['ohlc'])
for x, y in tick[0].items():
print("Key - Value ", x, y)
#data_dict = tick[0]
# print(data_dict)
#data = pd.DataFrame(data_dict)
#print(data)
#print(pd.DataFrame(eval(tick)['ohlc'], columns=["open", "high", "low", "close"]))
# Callback for successful connection.
def on_connect(ws):
# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
ws.subscribe([5633])
# Set RELIANCE to tick in `full` mode.
#ws.set_mode(ws.MODE_FULL, [5633])
# Assign the callbacks.
kws.on_tick = on_tick
kws.on_connect = on_connect
# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()
If it support, then i guess the code that I have written should work ?