Retrieve some chemistry industry companies' data using API

I want to pull some time series metrics (Revenue, Market Cap, P/E, Interest Costs, Earnings, etc.) for the top 25 chemicals business (by market cap as of Sep 2022) in several different regions. How to get these data through API? Someone helps me to download the data in excel, but load of human Erros. Think if I can use Refinitiv API may ensure the accuracy of data retrieved. Thank you

Best Answer

  • @sarah.liu

    The function returns a Python dataframe so you can save it to a CSV file by using the following code.

    rics.to_csv("output.csv")

    You can also specify date fields in the field list, as shown below.

    rics, err = ek.get_data(screener_exp, fields = ['TR.Revenue.Date','TR.Revenue','TR.PE.Date','TR.PE','EARNINGS'])

    The output is:

    1667895456174.png

Answers

  • @sarah.liu

    Sorry about the issue that you are facing.

    You can use a screener expression with Eikon Data API to get the required RICs. Then, use the retrieved RICS to get the required data.

    The code looks like this:

    screener_exp = 'SCREEN(U(IN(Equity(active,public,primary))), IN(TR.HeadquartersRegion,"Asia"), IN(TR.GICSIndustryCode,"151010"), TOP(TR.CompanyMarketCap(SDate=2022-09-30), 25, nnumber), CURN=USD)'


    rics, err = ek.get_data(instruments=[screener_exp], fields = ['TR.Revenue','TR.PE','EARNINGS'])
    rics

    The screener expression gets the top 25 chemicals business (IN(TR.GICSIndustryCode,"151010")) by market cap as of Sep 2022 (TOP(TR.CompanyMarketCap(SDate=2022-09-30)) in Asia (IN(TR.HeadquartersRegion,"Asia")).

    Then, use the retrieved items to get TR.Revenue, TR.PE and EARNINGS.

    The output is:

    1667796573392.png

    You can use the screener app to generate screener expressions and use the Data Item Browser to search for available fields.

    I hope that this information is of help

  • Thank you so much @Jirapongse on your comments, it really helps. I am not familiar with the platform. Do you know after I get the retrieve data table results, how to save it in the format I want (e.g. csv, excel etc.) and download to my local desktop? And also do you know how to show the date column corresponding to metrics in the data results? Thanks for your time and help in advance!

  • Thank you so much for your help! Appreciated.
  • @Jirapongse thanks for your response to my questions earlier. I'm now want to normalise the timeseries dataset, (get rid of some obvious outliers), do you know is there a function/way I can do that in the codebook or the Refinitiv workplace? Many thanks for your time in advance.
  • @sarah.liu

    The output is in Pandas Dataframe. You can use the Dataframe functions to manage the data. You can find a lot of examples via Google, such as Remove outliers from Pandas DataFrame.