It looks like you're new here. If you want to get involved, click one of these buttons!
from kiteconnect import KiteConnect
import logging
from kiteconnect import KiteTicker
logging.basicConfig(level=logging.DEBUG)
# Initialise
kws = KiteTicker(api_key, access_token)
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([53895943,256265])
# Set RELIANCE to tick in `full` mode.
ws.set_mode(ws.MODE_QUOTE, [53895943,256265])
def on_close(ws, code, reason):
# On connection close stop the main loop
# Reconnection will not happen after executing `ws.stop()`
ws.stop()
# kws.on_close = on_close
# Assign the callbacks.
kws.on_ticks = on_ticks
kws.on_connect = on_connect
# kws.on_close = on_close
kws.connect()
I am getting this error :
<del class="Delete"><del class="Delete"></del></del>ERROR:kiteconnect.ticker:Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
api_key , access_token, public_token has been provided for.
api_key is working properly. I checked it using this :
Code :
import logging
from kiteconnect import KiteTicker , KiteConnect
logging.basicConfig(level=logging.DEBUG)
# Initialise
kite = KiteConnect(api_key = api_key)
for instruments in kite.instruments('NFO'):
print(instruments)
break
Are you sure you used access_token? Maybe you used public token.
This code works perfectly alright.