Below is the code I am using that is an example of github import logging from kiteconnect import KiteTicker
logging.basicConfig(level=logging.DEBUG)
# Initialise
kws = KiteTicker("xxxxxx", "xxxxx")
def on_ticks(ws, ticks): # Callback to receive ticks. logging.debug("Ticks: {}".format(ticks))
def on_connect(ws, response): # Callback on successful connect. # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). ws.subscribe([738561])
# Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_FULL, [738561])
def on_close(ws, code, reason): # On connection close stop the main loop # Reconnection will not happen after executing `ws.stop()` ws.stop()
File "C:\Users\Mahinder\.spyder-py3\temp.py", line 36, in rs=kws.connect()
File "C:\Users\Mahinder\Anaconda3\lib\site-packages\kiteconnect\ticker.py", line 532, in connect reactor.run(**opts)
File "C:\Users\Mahinder\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1282, in run self.startRunning(installSignalHandlers=installSignalHandlers)
File "C:\Users\Mahinder\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1262, in startRunning ReactorBase.startRunning(self)
File "C:\Users\Mahinder\Anaconda3\lib\site-packages\twisted\internet\base.py", line 765, in startRunning raise error.ReactorNotRestartable()
Had similar trouble and was stuck for a long time. The following solution worked: 1. Refreshed the access_token . 2. Called it directly from the command prompt - not within Spyder / Jupyter.
1. Refreshed the access_token .
2. Called it directly from the command prompt - not within Spyder / Jupyter.