get list of RICs in chain 0#GRAINS/CASH
Hi,
I would like to get a list of all the RICs in the 0#GRAINS/CASH chain.
I tried:
df, err = ek.get_data('0#GRAINS/CASH', 'TR.CommonName')
or
df, err = ek.get_data('0#.GRAINS/CASH', 'TR.CommonName')
but I got the error: 'Unable to resolve all requested identifiers.'
I noticed this is a chain containing chains so I also tried
df, err = ek.get_data('0#CMAIZE-FR', 'TR.CommonName')
which should yield rics but the same problem occurred.
Exchanges seem to work fine as:
df, err = ek.get_data('0#.ftse', 'TR.CommonName')
works fine.
How can I get a list of all RICs in the GRAINS/CASH chain?
Best Answer
-
To retrieve chain constituents for any kind of chain, use a real-time field like DSPLY_NAME in get_data method instead of a fundamental & reference data field (aka TR.* field) like TR.CommonName. Try
ek.get_data('0#GRAINS/CASH', 'DSPLY_NAME')
0
Answers
-
Thank you @Alex Putkov. I managed to get the chains of the chain . I wrote your command into a recursive function that keeps digging down the RIC until it reaches the lowest level (code not starting with 0#). Then I calls some more data and append it to a pandas dataframe.
import eikon as ek
import pandas as pd
df_fin = pd.DataFrame(columns = ['Instrument', 'DSPLY_NAME', 'Instrument Description', 'Asset Category Description'])
def get_all_children(parent_ric, dsply_name):
logger.info(f"Call {parent_ric}")
df, err = ek.get_data(parent_ric, 'DSPLY_NAME')
for i, row in df.iterrows():
if str(row['Instrument']) == parent_ric:
logger.info(f'Skip {parent_ric} because it returned itself.')
return
elif str(row['Instrument']).startswith('0#'):
# the child is a chain
logger.info(f"Getting children of {str(row['Instrument'])}" )
get_all_children(str(row['Instrument']), str(row['DSPLY_NAME']))
else:
# the child is an instrument
logger.info(f"{str(row['Instrument'])} is not a chain so append df" )
df_child, err_child = ek.get_data(
instruments=str(row['Instrument']),
fields=[
'DSPLY_NAME',
'TR.InstrumentDescription',
'TR.AssetCategory']
)
# append to the global variable df_fin
global df_fin
df_fin = df_fin.append(df_child)
get_all_children('0#GRAINS/CASH', 'commodity')
df_fin.to_csv('out.csv', index=False)0 -
Hi, I find that this doesnt seem to work as i hit the limit i believe (400 error). Is there a way to adjust for that (some kind of sleep function?)0
-
Hi Shadeun. i just checked my code and we do it in a bit of a lazy fashion. we just go through them, and when we get an error, we wait 10 seconds and then try again (for max 20 times). give that a shot0
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛