@Pushwinder Have you called just_data() method, where kws is defined? Also, you can remove on_close method , if you want to keep reconnecting even after some error in between.
@rakeshr That's OK, I want to close the running program cleanly so that I could call it again without error. Mostly I use Ctrl+C to terminate the running program, is there any other means to terminate cleanly so that I can connect again.
You can go through this thread.
Now stuck at
kite.request_access_token(request_token="obtained_request_token",
secret="your_api_secret")
it says,
AttributeError: 'KiteConnect' object has no attribute 'request_access_token'
You are referring to older documentation, you need to refer version 3 document here.
I am able to run this only once:
def just_data():
kws = KiteTicker(api_key,access_token)
def on_ticks(ws,ticks):
print(ticks)
def on_connect(ws, response):
ws.subscribe([*])
ws.set_mode(ws.MODE_FULL,[*])
def on_close(ws, code, reason):
ws.stop()
kws.on_ticks=on_ticks
kws.on_connect=on_connect
kws.on_close = on_close
kws.connect()
What's missing??
Have you called just_data() method, where kws is defined?
Also, you can remove on_close method , if you want to keep reconnecting even after some error in between.
That's OK, I want to close the running program cleanly so that I could call it again without error.
Mostly I use Ctrl+C to terminate the running program, is there any other means to terminate cleanly so that I can connect again.
You can call ws.close() inside on_tick method,if you want to close websocket connection based on condition.
eg:
I am still getting this error
raise error.ReactorNotRestartable()
twisted.internet.error.ReactorNotRestartable
I am not able to take data using this syntax anymore,
ticks['last_price']
What is the alternative??