Upgrade from Eikon -> Workspace. Learn about programming differences.

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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 1 1 3

Extracting multiple historic relative valuation ratios via Eikon API (python)

Hi,

I'm hoping someone may be able to help me with the following issue. I'm new to python so this may seem like a novice request. Apologies in advance.

I wish to extract relative valuation data (P/E, P/B, P/S, EV/EBITDA - all TTM) on all S&P500 constituent stocks for the period 2006-2021 into a table on python. What is the cleanest way to code this? I have tried manually including each RIC & also (unsuccessfully) manipulating the 'peers' function.

I'm aware there will be leavers and joiners included in the dataset but that does not pose an issue to the research I then plan to complete on the dataset.

I've read numerous other threads that pose a similar question but I haven't been able to successfully alter their code to achieve my goal. I can share my code thus far if it helps.

Thank you!

eikon-data-apipythonhistoricalindexpeersvaluation
icon clock
10 |1500

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

Upvotes
Accepted
5.8k 21 2 6

Hi @student.02 ,


Please use the Data Item Browser to find the fields you're after

1657525341876.png


1657525362050.png


import refinitiv.data as rd
rd.open_session()
df1 = rd.get_history(
    universe=["0#.SPX"],
    fields=["TR.PE"],
    interval="1D",
    start="2021-10-01",
    end="2021-10-03",
)
display(df1)
rd.close_session()





1657525341876.png (107.4 KiB)
1657525362050.png (121.8 KiB)
icon clock
10 |1500

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


import refinitiv.data as rd
rd.open_session()
df1 = rd.get_history(
    universe=["0#.SPX"],
    fields=["TR.PE"],
    interval="1D",
    start="2021-10-01",
    end="2021-10-03",
)
display(df1)
rd.close_session()



1657525827966.png



1657525827966.png (39.5 KiB)
Upvote
14.2k 30 5 10

Hi @student.02 ,

Please let me add more information regarding the RD library that was mentioned by my colleague above, feel free to check the resources below those are related to the RD library

I hope this helps. However, you don't need to apologize for the question as we are happy to assist you regarding API usage.

icon clock
10 |1500

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

Upvotes
3 1 1 3

Hi jonathan.legrand and raksina.samasiri,

Great, thank you!

Is it then possible to re-write this code to extract the monthly returns for numerous ETFs for a given period? I have coded it in the following format, but my output is not as I would have expected; it appears as if the fund identifier codes I am using in this example (LP40119861, LP40119862, LP40039184) are not recognised.


image.png


Thanks!

icon clock
10 |1500

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

Hi @student.02, Please use the Data Item Browser to find the fields you're after; you might be after revenues more than returns, but they are only released along with financial statements, and they look like they're released every quarter only. You may want to interpolate monthly data in a technique such as the one outlined here: Using the Holt Winters Model to Interpolate GDP Values. You can use the comments section on YouTube if you have any questions.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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