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!
Best Answer
-
Hi @student.02 ,
Please use the Data Item Browser to find the fields you're after
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()2
Answers
-
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()0 -
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.
1 -
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.
Thanks!
0 -
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.
1
Categories
- All Categories
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛