Python client 3.0 is out with WebSocket class for live streams

  • muke5hy
    I am running example code but getting an error.

    ERROR:websocket:error from callback >: _on_close() takes exactly 1 argument (2 given)

  • Vivek
    @muke5hy We have released a patch for Python client - 3.1. Please check it out.
  • muke5hy
    Thanks @vivek tried it still not getting any response in this hour, Will it give any result when running after closing time ?

    Also pip is still on 3.0
  • pybull
    I am having problems with the SSL certificates when I try to use the websocket API. The openssl s_client shows "unable to get local issuer certificate". Am I missing some intermediate certificate files? I have disabled certificate verification for the time being, for my testing, but will need to fix this when I push my code to production. Any workarounds for this?
  • Kailash
    @pybull hm, you shoudn't have to do that. We use a Geotrust cert and the intermediary/root CAs should be in your local trust store.
  • sunnypatel
    can I use WebSocket on my local machine or I have to purchase some web server, if yes can you guide me on this?
  • tonystark
    @sunnypatel, Of course, you can use WebSocket on your local machine. You can follow the example code in the documentation.
  • pybull
    pybull edited February 2018
    Hi @Kailash,

    I have migrated my app to kite connect 3.0. However, I can't seem to get the ticker up, with the new websocket library. The following is the twisted log

    2018-02-10 13:08:51+0530 [-] Starting factory
    2018-02-10 13:08:52+0530 [-] failing WebSocket opening handshake ('WebSocket connection upgrade failed (403 - Forbidden)')
    2018-02-10 13:08:52+0530 [-] dropping connection to peer tcp4:35.154.180.164:443 with abort=True: WebSocket connection upgrade failed (403 - Forbidden)
    2018-02-10 13:08:52+0530 [-] will retry in 6 seconds
    2018-02-10 13:08:52+0530 [-] Stopping factory

    The corresponding log from the kite connect client is

    [2018-02-10 13:08:52,081] {kiteconnect/ticker.py:191} ERROR websocket - Try reconnecting. Retry attempt count: 1
    [2018-02-10 13:08:58,889] {myapp.py} ERROR - Websocket error code: 1006, reason: connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    [2018-02-10 13:08:58,890] {myapp.py} ERROR - Websocket closed code: 1006, reason: connection was closed uncleanly (WebSocket connection upgrade failed (403 - Forbidden))
    [2018-02-10 13:08:58,890] {kiteconnect/ticker.py:188} ERROR pybull.websocket - WebSocket connection lost: [Failure instance: Traceback (failure with no frames): : Connection was aborted locally, using.
    ].

    I had been trying to debug this over the last weekend, but to no avail. The last resort for me would be to switch back to the older websocket client, which used to work fine, but I would love to try the current autobahn websocket, before giving up.

    Any suggestions on what I should be trying to fix this?

    EDIT: Found a discussion on the same in an old thread. Seems like it is an issue with my access token. Will fix that
  • archulysses
    archulysses edited February 2018
    I am just starting with kite connect API's, so which version of python should I work with 2 or 3.
    i.e pykiteconnect is implemented in python 2 or 3?
  • sujith
    sujith edited February 2018
    @pybull,
    You need to send a valid access token to use new websockets API. Make sure your access token is valid.

    @archulysses,
    You need to use Kite Connect 3 (kite3 branch).
    pykiteconnect is compatible with both python 2 and 3.
  • pybull
    @sujith, thanks, I was using the public token from the previous API instead of the changed API.

    On a side note, I get a notification that kite 2.0 will be phased out soon. But the login through my kite connect app, happens through kite 2.0 instead of 3.0. I am already using the kite3 branch. Do I need any additional configuration (I suppose the python client automatically sends a header containing kite 3.0 in the request)? Or will the app continue to authenticate using kite 2.0?
  • sujith
    @pybull,
    There is a new login URL, wherein you need to append query param v=3, now authorization tokens have to be sent in the header and X-Kite-Version has to be sent via header.
    You can check out documentation for more details and cURL example requests
  • sriram73405
    I was not getting the ticks in the event callbacks for the whole day, today. onconnect and close callbacks were working fine but not the onticks callback. Extremely dissatisfied, since we are losing out on time and also money. Please resolve the issue as soon as possible.
  • sujith
    @sriram73405,
    It was a trading holiday yesterday. Hence there were no ticks.
  • SWAPNILMEHTA
    Anyone please guide me how can I code a strategy & use it to trade through Zerodha . I want to do it but I have no idea .
  • sujith
    @SWAPNILMEHTA,
    Please don't hijack threads.
    Kite Connect is purely an execution platform. We don't provide any kind of solution or support for writing strategies.
    You can check out this thread to look at some of the examples written by community members.
  • RajeshSivadasan
    My program runs infinitely and I have to press Ctrl+C to stop. How do I exit the program gracefully after market hours? What happens to the websocket callbacks post market hours?
  • sujith
    You can call unsubscribe and then call close method. You can check out python documentation here.
  • nikhil154
    What is the call rate as per the new websocket ?
  • sujith
    @nikhil154,
    You can open up to 3 websocket connections per app and you can subscribe for up to 3000 instruments with one websocket connection.
Sign In or Register to comment.