How to get the associated countries in a list of revenue fractions via Eikon API

Hello, I'm working with the Eikon API via Python and am trying to obtain the associated list of the top 20 countries that are associated with the 20 countries returned by the "Country of Risk Revenue Fraction" data item. The code below gives me the list of revenue fractions, but not the countries themselves to compare with (I need to compare several companies using this variable and the overlaps across countries).


df, err = ek.get_data(
instruments = ['AAPL.O'],
fields = ['TR.CoRRevenueFraction']
)
display(df)


Would you be able to help me modify the API call to return both the revenue fraction AND the associated country list?

Many thanks in advance for your help

Best Answer

  • aramyan.h
    aramyan.h admin
    Answer ✓

    Hi @AAMZ ,


    Thank you for your question. Consider adding 'TR.CoRRevenueFraction.countryname' to your fields parameter:

    df, err = ek.get_data(
    instruments = ['AAPL.O'],
    fields = ['TR.CoRRevenueFraction', 'TR.CoRRevenueFraction.countryname']
    )
    display(df)

    screenshot-2023-04-11-at-130349.png


    You may check for additional value output parameters from CodeCreator app in Eikon/Workspace:

    screenshot-2023-04-11-at-130443.png


    Hope this helps.


    Best regards,

    Haykaz


Answers

  • AAMZ
    AAMZ Explorer
    Thank you very much, this is exactly what I was looking for. Thanks also for the quick reply!

    Have a nice rest of the day

  • Hi !

    Hope this find you all well.

    What about looking for a specific list of countries and multiple ISINs.

    My code should work but in fact doesnt.

    Could someone kindly help me.

    import refinitiv.data as rd
    import pandas as pd
    rd.open_session()

    countries = pd.read_excel("List_Of_Countries.xlsx")
    isin= pd.read_excel("List_Of_ISIN.xlsx")
    display(countries)
    display(isin)

    isin_list = isin['Unnamed: 0'].iloc[1:].tolist()
    countries_list = countries.iloc[0, :].tolist()

    GeoRaw = rd.get_data(
    universe = isin_list,
    fields = ['TR.CoRRevenueFraction'],
    parameters = countries_list
    )

    display(GeoRaw)

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @MyScreenName

    The code should be like this:

    ld.get_data(
        universe = ['IBM.N'],
        fields  = ['TR.CoRRevenueFraction','TR.CoRRevenueFraction.ISO2Code'],
        parameters = {'CountryCode':'US,GB,FR'})
    

    If you have additional questions, feel free to submit them as separate questions.