Discover Refinitiv
MyRefinitiv Refinitiv Perspectives Careers
Created with Sketch.
All APIs Questions & Answers  Register |  Login
Ask a question
  • Questions
  • Tags
  • Badges
  • Unanswered
Search:
  • Home /
  • Eikon Data APIs /

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

avatar image
Question by valstar · Aug 10, 2021 at 12:59 PM · eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonchain-riccommodities

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?


People who like this

0 Show 0
Comment
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

2 Replies

  • Sort: 
avatar image
REFINITIV
Best Answer
Answer by Alex Putkov.1 · Aug 10, 2021 at 02:36 PM

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')
Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

avatar image
Answer by valstar · Aug 19, 2021 at 07:18 AM

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)


Comment

People who like this

0 Show 0 · Share
10 |1500 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Watch this question

Add to watch list
Add to your watch list to receive emailed updates for this question. Too many emails? Change your settings >
12 People are following this question.

Related Questions

Option Chain Quotes for Commodities (GOLD & SILVER)

Download AllCoCo list in python

Is there a way to pull complete option chain including weekly expiries?

Historical option chains

ek.get_data on option chain ticker

  • Copyright
  • Cookie Policy
  • Privacy Statement
  • Terms of Use
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Alpha
  • App Studio
  • Block Chain
  • Bot Platform
  • Connected Risk APIs
  • DSS
  • Data Fusion
  • Data Model Discovery
  • Datastream
  • Eikon COM
  • Eikon Data APIs
  • Electronic Trading
    • Generic FIX
    • Local Bank Node API
    • Trading API
  • Elektron
    • EMA
    • ETA
    • WebSocket API
  • Intelligent Tagging
  • Legal One
  • Messenger Bot
  • Messenger Side by Side
  • ONESOURCE
    • Indirect Tax
  • Open Calais
  • Open PermID
    • Entity Search
  • Org ID
  • PAM
    • PAM - Logging
  • ProView
  • ProView Internal
  • Product Insight
  • Project Tracking
  • RDMS
  • Refinitiv Data Platform
    • Refinitiv Data Platform Libraries
  • Rose's Space
  • Screening
    • Qual-ID API
    • Screening Deployed
    • Screening Online
    • World-Check One
    • World-Check One Zero Footprint
  • Side by Side Integration API
  • TR Knowledge Graph
  • TREP APIs
    • CAT
    • DACS Station
    • Open DACS
    • RFA
    • UPA
  • TREP Infrastructure
  • TRKD
  • TRTH
  • Thomson One Smart
  • Transactions
    • REDI API
  • Velocity Analytics
  • Wealth Management Web Services
  • Workspace SDK
    • Element Framework
    • Grid
  • World-Check Data File
  • 中文论坛
  • Explore
  • Tags
  • Questions
  • Badges