how to import websocket from kiteconnect

Solutions on MaxInterview for how to import websocket from kiteconnect by the best coders in the world

showing results for - "how to import websocket from kiteconnect"
Hawa
08 May 2018
1from kiteconnect import WebSocket
2
3# Initialise.
4kws = WebSocket("your_api_key", "your_public_token", "logged_in_user_id")
5
6# Callback for tick reception.
7def on_tick(tick, ws):
8	print tick
9
10# Callback for successful connection.
11def on_connect(ws):
12	# Subscribe to a list of instrument_tokens (RELIANCE and ACC here).
13	ws.subscribe([738561, 5633])
14
15	# Set RELIANCE to tick in `full` mode.
16	ws.set_mode(ws.MODE_FULL, [738561])
17
18# Assign the callbacks.
19kws.on_tick = on_tick
20kws.on_connect = on_connect
21
22# Infinite loop on the main thread. Nothing after this will run.
23# You have to use the pre-defined callbacks to manage subscriptions.
24kws.connect()