jugaad-trader
jugaad-trader copied to clipboard
Not able to connect to ticker
Not able to connect to ticker
I guess this is a temporary error from Zerodha sides. Now it is working fine.
I'm also not able to connect to ticker. @luckyIITR How did you fix it?
enc_token is modified only for kite ticker.
enc_token = enc_token.replace("+", "%2B") enc_token = enc_token.replace("/", "%2F") enc_token = enc_token.replace("=", "%3D")
This worked for me.
Which KiteConnect version are you using? Is this change to be done for older version or 2.9.2?
I modified this method as per your suggestion, still not working.
def ticker(self, api_key='kitefront', enctoken=None, userid=None):
if enctoken is not None:
self.enctoken = self.r.cookies['enc_token']
if userid is not None:
self.user_id = self.user_id
if self.user_id is None:
raise Exception("\nCould not find the session, Please start a session using \n\n$ jtrader zerodha startsession")
enc_token = self.enc_token.replace("+", "%2B")
enc_token = enc_token.replace("/", "%2F")
enc_token = enc_token.replace("=", "%3D")
return KiteTicker(api_key=api_key, access_token=enc_token+'&user_id='+self.user_id, root='wss://ws.zerodha.com')
Its working for me.. I just updated Kite to latest version without any modification to enc_token.
def on_ticks(ws, ticks): # Callback to receive ticks. print(ticks) #print(kws.is_connected()) 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_FULL, [738561])
def on_close(ws, code, reason):
# On connection close stop the event loop.
# Reconnection will not happen after executing ws.stop()
ws.stop()
##Assign the callbacks. kws.on_ticks = on_ticks kws.on_connect = on_connect kws.on_close = on_close
##Infinite loop on the main thread. Nothing after this will run. ##You have to use the pre-defined callbacks to manage subscriptions. kws.connect()
code copied from here.. it was not displaying anything initially so for testing i have directed printed ticks parameter.. https://kite.trade/docs/pykiteconnect/v3/ticker.m.html
@ssheikh098 @luckyIITR How is ticker working for you guys ? I am getting below error : Connection error: 1006 - connection was closed uncleanly (WebSocket connection upgrade failed (400 - BadRequest))
@smilinrobin For me, it is working fine. Keep in mind that if you disconnect the ticker once, you need to restart the kernel to start ticker again.
@luckyIITR which version of KiteConnect are you using. Its not working on mine 3.8.2
$ pip3 list | grep kiteconnect kiteconnect 3.8.2
Solved this by installing jugaad-trader from source. For some reason installation using pip doesn't work. May be there might be a need for version upgrade as the upgrade command doesn't work and I see the old source in the pip installation.
Steps followed:
- Clone from github
-
cd
to directory - Installed using
python3 setup.py install --prefix /home/user/.local/
this issue persists. i tried to fix but going nowhere.
@ashishanand7
if this has not resolved, then try these steps - https://github.com/jugaad-py/jugaad-trader/issues/44#issuecomment-1200493371
this issue persists. i tried to fix but going nowhere.
Refer to this issue. This solution worked for me https://github.com/jugaad-py/jugaad-trader/issues/44#issuecomment-1200493371