Streaming data output shows only one iteration data and does not stream

Sudheer
I run the below code in pycharm and anaconda and both ways I just get a single iteration output, please help me as to what I'm I missing on.


from kiteconnect import KiteConnect
from kiteconnect import WebSocket

api_key = "XXX"
public_token = 'XXX'
user_id = "XXX"
tokens = (14607362, 533155)
kws = WebSocket(api_key, public_token, user_id)


def on_tick(tick,ws):
# import sys
# sys.stdout=open("XXX.txt","w")
print(tick), "\n"
# sys.stdout.close()


def on_connect(ws):
ws.subscribe(tokens)
ws.set_mode(ws.MODE_FULL,tokens)


kws.on_tick = on_tick
kws.on_connect = on_connect

kws.connect()

@sujith @botany02 @Kailash
please address my query.
  • rakeshr
    Hi @Sudheer ,
    For second scrip JUBLFOOD, you are entering exchange token instead of instrument token.Change second token parameter from 533155 to 4632577.You can download entire instrument list dump(go through this documentation) and check
  • Sudheer
    @rakeshr thank you for your response, I changed it.. and I still got just one iteration of data and the prompt doesn't move any further.

    I have attached the screenshot of it, the prompt just stays there forever with no new data being updated.

  • sujith
    @Sudheer,
    Markets are closed on weekends. You will get only one cached tick for each instrument. Try tomorrow after the market opens.
  • Sudheer
    @sujith - I tried now, it worked :) thanks
This discussion has been closed.