It looks like you're new here. If you want to get involved, click one of these buttons!
count = 0
while True:
count += 1
print("This is main thread. Will change webosocket mode every 5 seconds.")
if count % 2 == 0:
if kws.is_connected():
ws.subscribe(tokens)
print("Set mode to LTP")
kws.set_mode(kws.MODE_LTP, tokens)
else:
if kws.is_connected():
ws.subscribe(tokens)
print("Set mode to quote")
kws.set_mode(kws.MODE_QUOTE, tokens)
time.sleep(5)
Dont we have to resubscribe tokens ? so that the code becomes-
count = 0
while True:
count += 1
print("This is main thread. Will change webosocket mode every 5 seconds.")
if count % 2 == 0:
if kws.is_connected():
print("Set mode to LTP")
kws.set_mode(kws.MODE_LTP, tokens)
else:
if kws.is_connected():
print("Set mode to quote")
kws.set_mode(kws.MODE_QUOTE, tokens)
time.sleep(5)
PS: I have updated the gist
For me, I would like to write streaming data in a file with minor calculations, for eg. making 1 min candles.
That will be much helpful.
Thanks