It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import KiteConnect
from kiteconnect import KiteTicker
import logging
request_token = open("request_token.txt",'r').read()
key_secret = open("api_key.txt",'r').read().split()
kite = KiteConnect(api_key=key_secret[0])
data = kite.generate_session(request_token, api_secret=key_secret[1])
#create KiteTicker object
kws = KiteTicker(key_secret[0],data["access_token"])
tokens = [738561, 5633]
def on_ticks(ws,ticks):
# Callback to receive ticks.
logging.debug("Ticks: {}".format(ticks))
print(ticks)
def on_connect(ws,response):
# Callback on successful connect.
logging.debug("on connect: {}".format(response))
ws.subscribe(tokens)
#ws.set_mode(ws.MODE_FULL,tokens)
kws.on_ticks=on_ticks
kws.on_connect=on_connect
kws.connect()
#########################################################################################Traceback (most recent call last):
File "<ipython-input-70-afaa4a2e484c>", line 19, in <module>
kws.connect()
File "C:\Users\User\Anaconda3\lib\site-packages\kiteconnect-3.8.0-py3.6.egg\kiteconnect\ticker.py", line 534, in connect
reactor.run(**opts)
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 1282, in run
self.startRunning(installSignalHandlers=installSignalHandlers)
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 1262, in startRunning
ReactorBase.startRunning(self)
File "C:\Users\User\AppData\Roaming\Python\Python36\site-packages\twisted\internet\base.py", line 765, in startRunning
raise error.ReactorNotRestartable()
ReactorNotRestartable
Your code is working fine at our end. Can you make sure that you have installed twisted properly at your end?
You can follow this method to install Twisted in the window's environment.
Please share the correct sample ticker example as given links are not working
https://github.com/zerodhatech/pykiteconnect/blob/kite3/examples/threaded_ticker.py
@rakeshr
You can check it here.