It looks like you're new here. If you want to get involved, click one of these buttons!
#!python
from kiteconnect import KiteConnect
from kiteconnect import WebSocket
api_key= xxx
public_token=yyy
user_id=zzz
access_token=ppp
kite = KiteConnect(api_key=api_key)
# Initialise. api_key, public_token, user_id are correct just as obtained.
kws = WebSocket(api_key, public_token, user_id)
# Callback for tick reception.
def on_tick(tick, ws):
print tick
# Callback for successful connection.
def on_connect(ws):
# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
ws.subscribe([738561, 5633])
# Set RELIANCE to tick in `full` mode.
ws.set_mode(ws.MODE_FULL, [738561])
#Reconnection command added by me as a backup measure.
def on_close(ws):
ws.reconnect()
# Assign the callbacks.
kws.on_tick = on_tick
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()
Am I missing something? I want to have a live stream during market hours today. Can you please guide me?
Thanks
My Linux terminal just returns back just after I run the above script without giving me any output. There is no data or live streaming. I installed the python client only. Do I need to install anything extra for websocket?
Thanks for the code. I ran it after putting the right values of api_key, public_token,user_id, access_token but the problem still exists.
The terminal just comes back without streaming any data or showing any errors.
There is no log output as well. I am using python 2.7. This is what I get in my terminal after I run the script three times:
Soumya:~/Trading-Algo> python webeditsocket.py
Soumya:~/Trading-Algo> python webeditsocket.py
Soumya:~/Trading-Algo> python webeditsocket.py
Soumya:~/Trading-Algo>
Thanks
There is no "print" command in my script. But WebSocket should stream the data just after the command "kws.connect()". Please let me know if thats correct.
I will see and keep you guys updated.
Thanks
I dont know how to bypass that and if that will hamper my security. Any suggestions?
ws
sowss
is the right way to use.I can connect to other "wss" sites and get a response from them. But only wss://websocket.kite.trade is the problem.
https://www.sslshopper.com/ssl-checker.html#hostname=websocket.kite.trade
What certificates should I be installing?
We'll release a patch today with some SSL settings tweaked. Let's see if that'll help.
pip install kiteconnect -U
You should pass the param
disable_ssl_verification=True
to the.connect()
method. Please not that this is a workaround, not a fix.The issue is due to a bug in OpenSSL itself -- https://github.com/liris/websocket-client/issues/35
The actual solution would be to update OpenSSL itself.