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
21 1 1 2

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
eikoneikon-data-apipythonprice-history
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.

1 Answer

· Write an Answer
Upvote
Accepted
884 4 2 8

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()

1644792902471.png

Output DataFrame:

1644792960607.png

Try this out and please let me know if you were looking for something different


1644792902471.png (42.5 KiB)
1644792960607.png (43.6 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.

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.