zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
983 stars 470 forks source link

_on_close() takes exactly 1 argument (2 given) #5

Closed muke5hy closed 8 years ago

muke5hy commented 8 years ago

Getting an error, Am I missing something? Running it on python 2.7

ERROR:websocket:error from callback <bound method WebSocket._on_close of <kiteconnect.WebSocket object at 0x7fe8577c3210>>: _on_close() takes exactly 1 argument (2 given)


from kiteconnect import WebSocket
import logging
logging.basicConfig()

# Initialise.
kws = WebSocket(API_KEY, PUBLIC_TOKEN, USER_ID)

# Callback for tick reception.
def on_tick(tick, ws):
    print tick, ws

# 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])

# 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()