Eikon Data API Historical Data Retrieval
How do i retrieve the OHLCVm marketcap and price to book of all S&P500 stocks from 2010 to 2025 in a single call.
Is there a code for using ek.get_data
Best Answer
-
Hi @ken03 ,
I am afraid you can't ingest the information you are after via a single call.
One option is to use the following code by changing the date in a loop:
const_df, err = ek.get_data(instruments=["0#.SPX(20200101)"],
fields=["TR.PriceClose.date", "TR.PriceClose","TR.PriceOpen", "TR.PriceHigh", "TR.PriceLow" ],
parameters={"SDATE":"2020-01-01", "EDATE":"2020-01-01"}
)
const_dfA more effective approach though is:
1. request the initial constituent list as of the first day as shown above:
2. Request the historical joiners and leavers from that point on and then request the prices for those days only after constructing the SPX constituents for the change day. The joiner/leaver call is below:
const_changes, err = ek.get_data(instruments=".SPX",
fields = ["TR.IndexJLConstituentRIC", "TR.IndexJLConstituentRIC.date", "TR.IndexJLConstituentRIC.instrument",
"TR.IndexJLConstituentRIC.change","TR.IndexJLConstituentName"],
parameters={"SDATE":"2010-01-01","EDATE":"2024-03-12", 'IC':'B'}
)
const_changesHope this helps.
Best regards,
Haykaz
0
Answers
-
Hi aramyan,
what do you mean by changing the date in a loop?
2. Request the historical joiners and leavers from that point on and then request the prices for those days only after constructing the SPX constituents for the change day. What do you mean by this and how do i execute it?
Thanks
Ken
0 -
Hi Ken,
1. What I mean you would need to make a separate request for each day you want the constituents.
2. Let's say you have the constituents with the first code as of "2020-01-01". Then you can use the second code to get index Joiners and leavers from that day onwards. This will give you the joiner/leaver RIC along with the change date. Then for each change date you can construct the SPX constituents yourself (as you have the original constituents and the joiners/leavers for that date). Finally you can get the prices for that specific date and constituents by using ek.get_data.
Hope this clarifies the workflow.
Best regards,
Haykaz
0 -
so if i need the data for across a time period say for 3 years, how would i implement the above? one date at a time?
0 -
since the constituents doesn't change every day, you can get the constituents (along with the market cap and P/B) per the change date. See an example with one date below:
const_df, err = ek.get_data(instruments=["0#.SPX(20200101)"],
fields=["TR.CompanyMarketCap.date", "TR.CompanyMarketCap", "TR.PtoBPSMeanEst"],
parameters={"SDATE":"2020-01-01", "EDATE":"2020-01-01"}
)
const_df0 -
Hi Aramyan,
for those stocks which have been delisted are you still able to pull its data via the ric?
0 -
Hi Ken,
if the specific data is available, you will. For delisted instruments you would have RICs followed by ^ symbol and delisting date information. Please refer to ABMD.OQ^L22 RIC as an example shown in the screenshot above. As you see when requesting the constituents historically you will have the delisted RIC for a delisted instrument in the list allowing to pull the information directly.
0
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 中文论坛