It looks like you're new here. If you want to get involved, click one of these buttons!
kws = KiteTicker(api_key,api_secret, "USERID")
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_QUOTE)
# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
# Infinite loop on the main thread. Nothing after this will run.
# You have to use the pre-defined callbacks to manage subscriptions.
kws.connect()
################ ERROR ###################################
2018-01-29 09:33:55+0530 [-] Starting factory <kiteconnect.ticker.KiteTickerClientFactory object at 0x0000004505303710>
Traceback (most recent call last):
File "<ipython-input-25-d02bc3af8194>", line 23, in <module>
kws.connect()
File "C:\Anaconda3\lib\site-packages\kiteconnect\ticker.py", line 522, in connect
reactor.run(**opts)
File "C:\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1242, in run
self.startRunning(installSignalHandlers=installSignalHandlers)
File "C:\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1222, in startRunning
ReactorBase.startRunning(self)
File "C:\Anaconda3\lib\site-packages\twisted\internet\base.py", line 730, in startRunning
raise error.ReactorNotRestartable()
ReactorNotRestartable
below is the error that i get when i run the exact websocket code as per documentation
2018-01-30 09:18:08+0530 [-] Log opened.
2018-01-30 09:18:10+0530 [-] failing WebSocket opening handshake ('WebSocket connection upgrade failed (403 - Forbidden)')
2018-01-30 09:18:10+0530 [-] dropping connection to peer tcp4:52.66.33.111:443 with abort=True: WebSocket connection upgrade failed (403 - Forbidden)
2018-01-30 09:18:10+0530 [-] will retry in 3 seconds
I think you are looking at old ticker example. Check out new example here. You need to send api_key and access_token.
https://kite.trade/docs/pykiteconnect/v3/#kiteconnect.KiteConnect.quote.
Even in v3 docs old ticker example is used
@sujith @vivek .. finally got connected. With every tick i get this error along with the tick data.
how can i resolve this ?
[KiteTickerClientProtocol (TLSMemoryBIOProtocol),client] will retry in 2 seconds
2018-01-30 21:18:04+0530 [-] Stopping factory
2018-01-30 21:18:06+0530 [-] Starting factory
Tried using the code presented in https://github.com/zerodhatech/pykiteconnect/tree/kite3
for accessing webscokets. Unable to execute because of the following error. Can you please help me
#####Error
kws.connect()
Traceback (most recent call last):
File "", line 1, in
kws.connect()
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\kiteconnect-3.7.7-py3.7.egg\kiteconnect\ticker.py", line 534, in connect
reactor.run(**opts)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1260, in run
self.startRunning(installSignalHandlers=installSignalHandlers)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\twisted\internet\base.py", line 1240, in startRunning
ReactorBase.startRunning(self)
File "C:\Users\LENOVO\Anaconda3\lib\site-packages\twisted\internet\base.py", line 748, in startRunning
raise error.ReactorNotRestartable()
ReactorNotRestartable
You need to remove kws.is_connected() before kws.connect() and use it in different thread to know the websocket connection status, it returns boolean( True or False).
You can check an example here.
Please share the correct sample ticker example of python as given links are not working
https://github.com/zerodhatech/pykiteconnect/blob/kite3/examples/threaded_ticker.py
@sujith @Vivek
I would suggest checking out the API documentation and python documentation here.
I am using the code given by @Vivek in above comment
You can look at this thread.
I am using above code for websocket streming but getting below error @rakeshr can you please help me out here.
You can check a python example here.