How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????
-
Can anyone please explain me what is_
FEED_TOKEN= "your feed token"
token="channel you want the information of" #"nse_cm|2885&nse_cm|1594&nse_cm|11536"
task="task" #'mw'|'sfi'|'dp'
How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script????? -
Hi @rjamitsharma01 You need to find a feasible way to do it in java its a one time process let me text you in pc.
-
@admin is there any way to do this in java
-
IDE may not be showing all entries of the dataframe. If you are looking for RELAINCE-EQ then
df.loc[df['symbol'] == "RELIANCE-EQ"] token symbol name expiry strike lotsize instrumenttype exch_seg tick_size 3514 2885 RELIANCE-EQ RELIANCE -1 1 NSE 5
all entries which match RELIANCE
df.loc[df['symbol'].str.contains("RELIANCE")] token symbol name expiry strike lotsize instrumenttype exch_seg tick_size 2513 18974 RELIANCEPP-E1 RELIANCEPP -1 1 NSE 5 2578 12713 RELIANCE-BL RELIANCE -1 1 NSE 5 3280 22319 RELIANCEPP-BL RELIANCEPP -1 1 NSE 5 3514 2885 RELIANCE-EQ RELIANCE -1 1 NSE 5 11238 500325 RELIANCE RELIANCE -1 1 BSE 5 ... ... ... ... ... ... ... ... ... ... 71420 120461 RELIANCE27MAY212540CE RELIANCE 27MAY2021 254000 250 OPTSTK NFO 5 71553 112789 RELIANCE29APR211960PE RELIANCE 29APR2021 196000 250 OPTSTK NFO 5 71559 105028 RELIANCE25MAR211980PE RELIANCE 25MAR2021 198000 250 OPTSTK NFO 5 71742 105005 RELIANCE25MAR211760CE RELIANCE 25MAR2021 176000 250 OPTSTK NFO 5 71928 112813 RELIANCE29APR212200PE RELIANCE 29APR2021 220000 250 OPTSTK NFO 5 [421 rows x 9 columns]
-
@rajanprabu Sir it's showing like this____
my code is____import pandas as pd df = pd.read_json('http://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json') print(df)
-
Hi @ashmita Please refer the following code to generate feed token
######################################################
from smartapi import SmartConnectobj=SmartConnect(api_key="put your api key here")
data = obj.generateSession("put your client id here","put your passwd here")
refreshToken= data['data']['refreshToken']#fetch the feedtoken
feedToken=obj.getfeedToken()
print ("this is my feed token" ,feedToken )#fetch User Profile
userProfile= obj.getProfile(refreshToken)now you will have your feed token with you
##########################################################
now use below piece of code to use web socket use feed token which you will get from above 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( )
-
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
I'm not found instrument like Reliance_EQ,
Do you converted json into csv ?
You should use RELIANCE-EQ for equity.
RELIANCE25MAR21FUT for current month contractCan you share your code, so we can help you.
-
possible reliance search terms
RELIANCE-EQ
RELIANCE29APR211660CE
RELIANCE29APR21FUTIf one just wants to use the data they saw market API, otherwise trading API.
-
Hi @ashmita_ please mail us your piece of code @ api@angelbroking.com.
-
@James-Bond Sir I fetched this data in a dataframe but I'm not found instrument like Reliance_EQ, Reliance_Future, Reliance_Options
And sir can you please tell me what is the difference between Trading API and Market Feeds API
when I hover the cursor on I button it's show__
Trading API:- Access full fledged APIs to execute orders i real time, manage use portfolio, stream live market data and more.
Market Feeds APIs:- Access real time market data for various stocks. -
To subscribe multiple scrips at same time, use following format:
"nse_cm|2885&nse_cm|5285&nse_cm|2521&nse_cm|2854"
It should be separated by &
Getting token list:
@ashmita_ said in How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????:
Some one give me this link https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json but it's looks messy and confusing I can't understand how can I use it sir......
@rajanprabu answered your query in above post which is easiest approach to get scrip names and token lists.
-
You can read them in pandas.. Its in json format
df = pd.read_json('http://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json')
Python dictionaries are hashed.. so its faster. But if you prefer csv you can convert them like the following
df.to_csv(file_name)
-
@James-Bond Sir can you please tell me how to get the instruments token list including F&O contract's........
I'm using python sdk....
Some one give me this link https://margincalculator.angelbroking.com/OpenAPI_File/files/OpenAPIScripMaster.json but it's looks messy and confusing I can't understand how can I use it sir......
Also how to subscribe multiple script at the same time mean token format like this
token="nse_cm|2885, token=nse_cm|5285, token=nse_cm|2521, token=nse_cm|2854" -
@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.....