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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
40 1 3 2

Hourly Time Series with ek.get_timeseries

Hello,

What is the formula to get the hourly time series with API in Python ?


Thanks a lot.

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpythontime-seriesinterval
icon clock
10 |1500

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

Upvote
Accepted
4.3k 2 4 5

Hi,

You just have to specify the interval as below:

req = ek.get_timeseries(["MSFT.O"],
                        interval="hour")

Possible values: 'tick', 'minute', 'hour', 'daily', 'weekly', 'monthly', 'quarterly', 'yearly' (Default 'daily')


icon clock
10 |1500

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

Thanks for your answer.

It works very well, now can you please tell me how to decide the time zone ? it seems that all is using GMT timezone...

Upvotes
13k 32 12 18

Hi @emmanuel.chaslin, Please see this answer on how to specify the timezone in your timeseries call.

Essentially you can specify the timezone in the start and end periods. The returned data is always in UTC.

icon clock
10 |1500

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

Upvotes
40 1 3 2

Thanks Gurpeet,


However I dont see how to adapt my script to get the output (df) in my local time zone:


year=2019

print(year)

first_date = datetime(year,1,1)

last_date = datetime.today() + timedelta(days =1)

df =pd.DataFrame(ek.get_timeseries(ric, start_date=first_date,end_date = last_date,interval="hour"))


Thanks in advance.

icon clock
10 |1500

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

Upvote
4.3k 2 4 5

Hi

last_date is incorrect because datetime.today() + timedelta(days =1) is in the future

I suppose you want to get timeseries from 1st of January, 2019. If I'm right, you don't have to set end_date (because default end_date is today())

This should help you:

import eikon as ek
from datetime import datetime
from dateutil.tz import tzlocal

year=2019
print(year)
first_date = datetime(year,1,1, tzinfo=tzlocal())
df =ek.get_timeseries("AAPL.O", start_date=first_date, interval="hour")
print(df)

                         HIGH       LOW        OPEN     CLOSE   COUNT    VOLUME
Date
2019-09-09 09:00:00   53.4500   53.2725   53.425000   53.4025      40      9948
2019-09-09 10:00:00   53.5175   53.4050   53.417500   53.4200      33      3328
2019-09-09 11:00:00   53.5750   53.4375   53.500000   53.5325      39     12700
2019-09-09 12:00:00   53.6400   53.5000   53.502500   53.5850     336    171268
2019-09-09 13:00:00   53.6900   53.5000   53.549925   53.6500     547    314024
...                       ...       ...         ...       ...     ...       ...
2020-09-04 20:00:00  127.9900  116.6476  121.480000  120.9000  392570  42388645
2020-09-04 21:00:00  453.2631  117.8411  120.905000  120.1000   17844  16822104
2020-09-04 22:00:00  129.1490  119.6200  120.100000  120.1500    8557   1934439
2020-09-04 23:00:00  120.2500  119.7700  120.150000  119.8200    2101    165211
2020-09-05 00:00:00  120.0600  119.3500  119.830000  120.0000    2630    209387

[4026 rows x 6 columns]

(ek.get_timeseries() already returns a DataFrame)

According to the interval, size of timeseries is limited. In this example, hourly timeseries starts from 2019-09-09.

And you can see that current range of date is too large because timeseries stops on 2020-09-05.

You'll have to reduce the range of date or update the interval to get a result that correspond to [start_date, end_date]

icon clock
10 |1500

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

Hi Pierre,

How do i add time to above code. Example: 07:00 local time.

Thanks,

@avishen.bablee

When asking a new question, please always start a new thread. Old threads with accepted answers are not monitored by forum moderators. If you need to reference an old thread, include the link to the thread in your post.
To answer your question, you can specify time in the datetime value passed to start_date kwarg of ek.get_timeseries method, e.g.

start_date = datetime(2021,5,20,7,0, tzinfo=tzlocal())
df =ek.get_timeseries("AAPL.O", start_date=start_date, 
                      interval="hour")

If you have any further questions, please post them on a new thread.

Click below to post an Idea Post Idea