It looks like you're new here. If you want to get involved, click one of these buttons!
def on_ticks(ws, ticks):
# Callback to receive ticks.
print("#######################")
print(ticks[0]['last_price'])
print("#######################")
global tick_count
tick_count = tick_count +1
print("TICK COUNT : ")
print(tick_count)
if(tick_count > 1):
print("inside if")
ws.unsubscribe([53718535])
ws.close()
def on_connect(ws, response):
# Callback on successful connect.
# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
try:
ws.subscribe([53718535])
# Set Crude to tick in `full` mode.
ws.set_mode(ws.MODE_FULL, [53718535])
except Exception:
print(Exception)
def on_close():
print("here")
# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
kws.on_close = on_close
kws.connect()
print("################ HEREEEEEE #############################")
tick_count = 0
kws.connect()
You can follow this thread.