Data streaming example not working

sovan_nit
Hi
I m trying to check data streaming using the example given in stream.py (https://github.com/zerodhatech/kite-connect-python-example/blob/master/stream.py)

however it is not working for me.

from kiteconnect import WebSocket

does WebSocket function exists in kiteconnect? i see that it is not able to find this.

can you please give an working example of data streaming .
  • rakeshr
    @sovan_nit
    You are using older version kite connect example.You can check Kite ticket python example here.
  • sovan_nit
    ok got it, thanks.. it is working now, however facing issue when trying with threaded option .

    kws.connect(threaded=True)

    an it is giving me this error:


    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 200 None.

    I need to subscibe to say 50 symbols and check their quotes and based on conditions i want to put buy/sell orders or modify existing positions . I assume kws.connect(threaded=True)
    will enable multi threading.so my question is
    1)In my case will multi threading improve the performance? is it required or single thread is sufficient in this case? if not when it is useful to have multi threading
    2) do i need to do anything extra apart from kws.connect(threaded=True) for multi threading?
    3) how to control/set the number of threads required for this? Suppose, if i want to have separate thread for each symbol , and strategy code for each symbol will be executed in parallel, how can this be achieved?
  • Vivek
    Vivek edited November 21
    @sovan_nit `threaded=True` runs the Ticker connection in separate thread instead of main thread, if you don't have `threaded=True` then it will be blocked in main thread when you do `kws.connect` call. Its not possible to have separate thread for each symbol, you can only run entire ticker in different thread and data will be sent to main thread via callbacks.
  • sovan_nit
    Hi @Vivek with `threaded=True` it is giving me below error? what could be wrong here?

    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 200 None.
  • rakeshr
    @sovan_nit
    DEBUG:urllib3.connectionpool:https://api.kite.trade:443 "POST /session/token HTTP/1.1" 200 None
    Above debug log is not an error, you need to make POST request to /session/token to get access_token, to be used further.You can look this documentation.
    Are you able to generate access_token successfully post login?
Sign In or Register to comment.