1. Home
  2. Article Catalog
  3. Retrieve Cross Economic Data using Eikon Data API(Python) | Refinitiv

Article

Retrieve Cross Economic Data using Eikon Data API(Python) | Refinitiv

Chavalit Jintamalit
Developer Advocate Developer Advocate

The article demonstrates steps to retrieve cross economic data from different countries.

 

Country Economic Indicator RIC is a chain RIC. (for more information on the chain RIC data structure, please refer to this article on "The chain data structure" section).

The chain RIC may contain multiple Economic Indicator RIC codes. (A sample Python code to expand the chain RIC is given at the end of this article.)

 

 

From this example, ECONALLHK contains the following ECI RIC codes:

    	
            

['HKFXR=ECI',

 'HKGDP=ECI',

 'HKGDPY=ECI',

 'HKCEYA=ECI',

 'HKPCYA=ECI',

 'HKEGYA=ECI',

 'HKESYA=ECI',

 'HKFCYA=ECI',

 'HKGDYA=ECI',

 'HKGDPA=ECI',

 'HKIGYA=ECI',

 'HKISYA=ECI',

 'HKIMPY=ECI',

 'HKCPIY=ECI',

 'HKCPIM=ECI',

 'HKCPIT=ECI',

 'HKIPY=ECI',

 'HKM3MS=ECI',

 'HKPPIY=ECI',

 'HKPMI=ECI',

 'HKRSL=ECI',

 'HKRSY=ECI',

 'HKTRD=ECI',

 'HKUNR=ECI',

 'HKOBOP=ECI']

Each Economic Indicator RIC also makes use of Illogical Field to carry the data.

What is Illogical Field

Fields value pairs which do not properly describe the meaning of the data. The majority, but not all illogical FID, is born from the Record Template restrictions on datafeed, where a venue has a restricted set of fields to code values against, and due to this constraint, new values provided by a venue are coded against existing fields plus generic fields (GEN_VAL). Illogical FID by definition is not constrained to static or dynamic fields, and manifests in both quote and trade data.

Due to the time-to-market demand, when there are many venues on datafeed share the same template, these venues have been forced to add the new values into the existing fields (which maybe no longer in use) ; as a result, there are many mismatched field-data pairs on datafeed.

The Generic FIDs (GN_TXTn) is a good example of the illogical FID used by Economic Indicator RIC.

 

Here are steps to get started

Knowing Country or Region Economic Identifier:

You can use the template provided within Eikon Excel to learn about each country or region Economic RIC code.

1. Launch Eikon Excel and sign-in on the "Thomson Reuters" tab.

2. Click on the "Templates" button and browser to "Cross Economic Data" on the popup window then click the "Open" button.

 

 

 

 

 

3. Browse to column AS to see country or region RIC code.

 

 

This article uses "Hong Kong", RIC code is ECONALLHK, to demonstrate the process to retrieve the cross economic data.

 

Getting all available Economic Indicators from a country or region Economic Identifier.

1. You can follow this code to retrieve a list of all underlying economic indicator Identifiers.

    	
            

#Step 2-1:

#Define getUnderlying() function

def getUnderlying(baseRic):

    LONGNEXTLR = baseRic

    #For LONGLINK1 to LONGLINK15 and LONGNEXTLR fields

    fields = ['LONGLINK{}'.format(x) for x in range(1, 15)]

    fields.append('LONGNEXTLR')

 

    all_underlying_rics = []

 

    #if LONGNEXTLR is not empty, try to retrieve the data fields

    while LONGNEXTLR!='':

        df,e = ek.get_data(LONGNEXTLR,fields)

        LONGNEXTLR = df.iloc[0]['LONGNEXTLR'] if pd.notnull(df.iloc[0]['LONGNEXTLR']) else ''

        

        #If LONGLINK<x> field is not null, append its value to all_underlying_rics list

        for x in range(1, 15):

            currentField = 'LONGLINK{}'.format(x)

            all_underlying_rics.append(df.iloc[0][currentField]) if pd.notnull(df.iloc[0][currentField]) else None

        #delay between each API call for 1 second

        time.sleep(1)

 

    #delete first 2 elements(not country indocators) from the list and return the remaining list

    del all_underlying_rics[0:2]

    return all_underlying_rics

 

 

#Step 2-2:

#Getting all underlying rics from ECONALLHK

HKIndicators = getUnderlying('ECONALLHK')

HKIndicators

 

This is output for Hong Kong Economic Indicator Identifiers:

    	
            

['HKFXR=ECI',

 'HKGDP=ECI',

 'HKGDPY=ECI',

 'HKCEYA=ECI',

 'HKPCYA=ECI',

 'HKEGYA=ECI',

 'HKESYA=ECI',

 'HKFCYA=ECI',

 'HKGDYA=ECI',

 'HKGDPA=ECI',

 'HKIGYA=ECI',

 'HKISYA=ECI',

 'HKIMPY=ECI',

 'HKCPIY=ECI',

 'HKCPIM=ECI',

 'HKCPIT=ECI',

 'HKIPY=ECI',

 'HKM3MS=ECI',

 'HKPPIY=ECI',

 'HKPMI=ECI',

 'HKRSL=ECI',

 'HKRSY=ECI',

 'HKTRD=ECI',

 'HKUNR=ECI',

 'HKOBOP=ECI']

 

2.    Here is the sample code to retrieve the values for each Economic Indicator RIC code:

Note that some fields here are illogical fields so the rename() function is used to demonstrate the real meaning of the illogical fields used here.

    	
            

#Step 3:

#Retrieve data point on each Economic Indicator

fields = ['TR.IndicatorName','TR.IndicatorType','TR.IndicatorSource'

          ,'GN_TXT16_3' #GMT Date

          ,'VALUE_TS1' #Time

          ,'CTBTR_1LL' #Period

          ,'GN_TXT16_4' #Actual

          ,'OFFC_CODE2' #Reuters Survey

          ,'CTBTR_1' #Prior

          ,'GN_TXT24_1' #Revised

         ]

df,e = ek.get_data(HKIndicators, fields)

 

#Rename dataframe columns

df.rename(columns={'GN_TXT16_3':'GMT Date'

    ,'VALUE_TS1':'Time'

    ,'CTBTR_1LL':'Period'

    ,'GN_TXT16_4':'Actual'

    ,'OFFC_CODE2':'Reuters Survey'

    ,'CTBTR_1':'Prior'

    ,'GN_TXT24_1':'Revised'

},inplace=True)

df

 

Here is the result in the df dataframe which contains the cross economic data: