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
    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

  • 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

  • You're welcome, happy to be helpful!