How to get fed_token and how to use token and task and how to subscribe and unsubscribe a script?????
-
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.
-
@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. -
Hi @ashmita_ please mail us your piece of code @ api@angelbroking.com.
-
possible reliance search terms
RELIANCE-EQ
RELIANCE29APR211660CE
RELIANCE29APR21FUTIf one just wants to use the data they saw market API, otherwise trading API.
-
@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.
-
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( )
-
@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)
-
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]
-
@admin is there any way to do this in java
-
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.