N
@sevrus
from smartWebSocketV2 import SmartWebSocketV2
For Live NIFTY, BANKNIFTY LTP
AUTH_TOKEN =
angelapikey =
feed_token =
client_code =
correlation_id = "live_data"
action = 1
mode = 1
sws = SmartWebSocketV2(AUTH_TOKEN, angelapikey, client_code, feed_token)
token_Nifty = "26000"
token_Bank = "26009"
token_Fin = "26037"
token_Mid = "26074"
token_list = [{"exchangeType": 1, "tokens": [token_Nifty,token_Bank,token_Fin,token_Mid]}]
def on_data(wsapp, message):
# print("Ticks: {}".format(message))
token = message['token']
last_price = message['last_traded_price']
last_price = last_price/100
def on_open(wsapp):
print("\n------Options Live LTP subscribed------")
sws.subscribe(correlation_id, mode, token_list)
def on_error(wsapp, error):
print(error)
def on_close(wsapp):
print("Close")
sws.on_open = on_open
sws.on_data = on_data
sws.on_error = on_error
sws.on_close = on_close
threading.Thread(target = sws.connect).start()
"" Do check the indent correctly ""