Historic share prices time frame gap
Dear All,
I am trying to obtain historic daily CLOSE share prices with get_timeseries() in Python for the last 5 years. I am aware of the rics per request limitation, which is why I split it into portions of about 20.
I realised that the code does not give me the full time frame I specified, see data.info() return below limiting the return to 2019. However, when trying out single rics, e.g. AAPL it does seem to work.
I would appreciate some guidance on how to overcome this problem - thank you!
Dominic.
This is the code I use:
import eikon as ek
import cufflinks as cf
import configparser as cp
cf.set_config_file(offline=True)
ek.set_app_key('XXX')
rics = ['CNP.N', 'BA.N', 'LIN.N', 'WY.N', 'MCD.N', 'HD.N', 'AIG.N', 'COST.OQ', 'DIS.N', 'TRV.N', 'BBWI.N', 'LOW.N', 'SYY.N', 'MAS.N', 'CL.N', 'UNH.N', 'LLY.N', 'NWL.OQ', 'WMB.N', 'TXN.OQ']
data = ek.get_timeseries(rics,
start_date='2017-01-03',
end_date='2021-12-31',
fields='CLOSE',
interval='daily')
data.info()
<class 'pandas.core.frame.DataFrame'>
DatetimeIndex: 150 entries, 2019-02-22 to 2021-12-31
Data columns (total 20 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 CNP.N 150 non-null Float64
1 BA.N 150 non-null Float64
2 LIN.N 150 non-null Float64
3 WY.N 150 non-null Float64
4 MCD.N 150 non-null Float64
5 HD.N 150 non-null Float64
6 AIG.N 150 non-null Float64
7 COST.OQ 150 non-null Float64
8 DIS.N 150 non-null Float64
9 TRV.N 150 non-null Float64
10 BBWI.N 150 non-null Float64
11 LOW.N 150 non-null Float64
12 SYY.N 150 non-null Float64
13 MAS.N 150 non-null Float64
14 CL.N 150 non-null Float64
15 UNH.N 150 non-null Float64
16 LLY.N 150 non-null Float64
17 NWL.OQ 150 non-null Float64
18 WMB.N 150 non-null Float64
19 TXN.OQ 150 non-null Float64
dtypes: Float64(20)
memory usage: 27.5 KB
Best Answer
-
Hi @student.5,
There are certain limitations to number of data points retrieved using get_timeseries() function. You can only retrieve 3000 data points for interday intervals. That's why when you requested for time series data for 20 RICs using get_timeseries() function, it just retrieved 20*150=3000 data points.
For more information on api limitations you can read here.
To retrieve historical data for 5 years, you can look at get_data() function. Below is the sample code:
import eikon as ek
ek.set_app_key('APP_KEY')
rics = ['CNP.N', 'BA.N', 'LIN.N', 'WY.N', 'MCD.N', 'HD.N', 'AIG.N', 'COST.OQ', 'DIS.N', 'TRV.N', 'BBWI.N', 'LOW.N', 'SYY.N', 'MAS.N', 'CL.N', 'UNH.N', 'LLY.N', 'NWL.OQ', 'WMB.N', 'TXN.OQ']
data, err = ek.get_data(rics, ['TR.PriceClose', 'TR.PriceClose.Date'],
{'sdate':'2017-01-03',
'edate':'2021-12-31',
'Frq':'D'})
data.info()Output DataFrame:
Try this out and please let me know if you were looking for something different
1
Categories
- All Categories
- 6 AHS
- 39 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
- 60 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛