request_token = "" # generate this before trading api_key = "" secret = "" kite = KiteConnect(api_key=api_key)
data = kite.generate_session(request_token, secret) kite.set_access_token(data["access_token"]) kt = KiteTicker(api_key,secret) # Assign the callbacks. def on_ticks(ws, ticks): # noqa # Callback to receive ticks. print("within on_ticks") logging.info("Ticks: {}".format(ticks)) print(ticks)
def on_connect(ws, response): # noqa # Callback on successful connect. # Subscribe to a list of instrument_tokens (RELIANCE and ACC here). print("within on_connect") ws.subscribe([738561, 5633])
# Set RELIANCE to tick in `full` mode. ws.set_mode(ws.MODE_FULL, [738561])
Where do you see KiteTicker(api_key,api_secret) in the sample code?? It's clearly mentioned in the documentation that it's KiteTicker(api_key,access_token). https://github.com/zerodha/pykiteconnect
Sample code provided by you is
kt = KiteTicker(api_key, secret)
what worked for me is
kt = KiteTicker(api_key, request_token)
https://github.com/zerodha/pykiteconnect