Facing problem when streaming the live data
-
Can anyone please help me when I trying to fetched real time data using this code
from smartapi import SmartConnect from smartapi import WebSocket obj = SmartConnect(api_key=apikey) data = obj.generateSession(client_token, password) feedToken = obj.getfeedToken() FEED_TOKEN = feedToken CLIENT_CODE = client_token task = "mw" # 'mw'|'sfi'|'dp' token = "nse_cm|26009" WS = WebSocket(FEED_TOKEN, CLIENT_CODE) def on_tick(ws, tick): print(tick) def on_connect(ws, response): ws.send_request(token) # def on_close(ws, code, reason): # ws.stop() # Assign the callbacks. WS.on_ticks = on_tick WS.on_connect = on_connect # WS.on_close = on_close WS.connect()
it's display nothing like this____
can you please tell me what is happening????
I'm using python SDK -
if you using new 1.2.2 python SDK you need to send task parameter as well.
def on_connect(ws, response): ws.send_request(token,'mw')
-
Hi @nayan_nandi please try below piece of code.
from smartapi import WebSocket
FEED_TOKEN= ""
CLIENT_CODE=""
token= "nse_cm|2885&nse_cm|1594&nse_cm|11536"
task="mw" #'mw'|'sfi'|'dp'
ss = WebSocket(FEED_TOKEN, CLIENT_CODE)def on_tick(ws, tick):
print("Ticks: {}".format(tick))def on_connect(ws, response):
ws.send_request(token,task)def on_close(ws, code, reason):
ws.stop()Assign the callbacks.
ss.on_ticks = on_tick
ss.on_connect = on_connect
ss.on_close = on_closess.connect( )
-
@admin Sir when i run the code it's showing like this___
and sir can you please tell me how to get the scripts token list including equity, futures, options....... -
Hi @nayan_nandi Web socket only works in live markets so try it in market hours.
-
@admin Sir same problem in market hours
I'm using Trading API. And when I print feedToken it's print "None" my code is____from smartapi import SmartConnect from smartapi import WebSocket obj = SmartConnect(api_key=apikey) data = obj.generateSession(client_token, password) feedToken = obj.getfeedToken() print(feedToken) FEED_TOKEN = feedToken CLIENT_CODE = client_token token = "nse_cm|2885" # Token number of RELIANCE-EQ task = "mw" # 'mw'|'sfi'|'dp' ss = WebSocket(FEED_TOKEN, CLIENT_CODE) def on_tick(ws, tick): print("Ticks: {}".format(tick)) def on_connect(ws, response): ws.send_request(token, task) def on_close(ws, code, reason): ws.stop() ss.on_ticks = on_tick ss.on_connect = on_connect ss.on_close = on_close ss.connect()
-
Hi @nayan_nandi we are testing it from our side.we will update you on this.
-
@admin Sir any update ????
Same problem today also
-
@rajanprabu said in Facing problem when streaming the live data:
@nayan_nandi
if you using new 1.2.2 python SDK you need to send task parameter as well.
def on_connect(ws, response):
ws.send_request(token,'mw')did you try this @nayan_nandi ?
-
Hi @nayan_nandi we regret for the delay we will keep you updated on the issue.
-
@admin Sir can you please tell me what is the issue is happening???
And why it's happening....... -
Hi @nayan_nandi we have tried to handle all this issues in the new version of python sdk.We will be testing it and reverting you back.
-
Hi @nayan_nandi we have tested the web socket today it is working fine now.
-
@admin Sir the issues is not not resolve yet. Same problem facing today also....
Please do something.... -
Hi @nayan_nandi web socket is working fine from our end.
-
@admin So sir why i'm not getting feed. also when i trying to print feedToken it's show None what can i do.....
This is my code______from smartapi import SmartConnect from smartapi import WebSocket import creds obj = SmartConnect(api_key=creds.api_key) data = obj.generateSession(creds.client_token, creds.password) feedToken = obj.getfeedToken() print(feedToken) FEED_TOKEN = feedToken CLIENT_CODE = creds.client_token token = "nse_cm|2885" # Token number of RELIANCE-EQ task = "mw" # 'mw'|'sfi'|'dp' ss = WebSocket(FEED_TOKEN, CLIENT_CODE) def on_tick(ws, tick): print("Ticks: {}".format(tick)) def on_connect(ws, response): ws.send_request(token, task) # def on_close(ws, code, reason): # ws.stop() ss.on_ticks = on_tick ss.on_connect = on_connect # ss.on_close = on_close ss.connect()
-
Hi @nayan_nandi we will review the code and revert you back.
-
Hi @nayan_nandi try to restart you kernel and give a try.
-
@admin How can i do it sir??
-
Hi @nayan_nandi can you please restart your system and give a try.