How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????
-
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
Sir what is the meaning of task (task="mw" #'mw'|'sfi'|'dp')???
More info here: https://smartapi.angelbroking.com/docs/WebSocket
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
can we subscribe a script using symbol name like this "nse_cm|RELIANCE" instead of using token number like this way "nse_cm|2885" ???
No, we can't use something like nse_cm|RELIANCE. Only scrip token will be considered as acceptable value.
-
This post is deleted! -
@James-Bond Sir what is the meaning of task (task="mw" #'mw'|'sfi'|'dp')???
And sir can we subscribe a script using symbol name like this "nse_cm|RELIANCE" instead of using token number like this way "nse_cm|2885" ??? -
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
FEED_TOKEN= "your feed token"
SmartAPI SDK has inbuilt method to generate feed token, so you don't have to worry about it.
-
You can use following code to get Feed Token and subscribe any scrip.
from smartapi import SmartConnect from smartapi import WebSocket obj=SmartConnect(api_key="your_api_key") data = obj.generateSession('client_id', 'password') feedToken=obj.getfeedToken() FEED_TOKEN= feedToken CLIENT_CODE= 'client_id' 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()
To subscribe Reliance (NSE), first you need to find out Reliance scrip / symbol token from following JSON file.
https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json
then you need to change token in above code. In case of RELIANCE-EQ token is 2885
so change:token="nse_cm|26009"
to
token="nse_cm|2885"
To use above code, you need to update above code with your api key, client id and password.
-
This post is deleted! -
@James-Bond I'm using python SDK. Can you please tell me how to get this FEED_TOKEN= "your feed token"......./
And how to subscribe it mean, code format if we want to subscribe NSE_RELIANCE script..... -
@James-Bond I'm using python sdk....
-
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????
It's mainly depends on which programming language you're using.
-
Which SDK you're using ?
In case of Python or with any other language, Feed token generally used to access WebSocket to receive live ticks.
Tokens are primarily used to subscribe particular scrip to receive live ticks.