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.
Best Answer
-
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')
1
Answers
-
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...0 -
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.
0 -
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.
0 -
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]
1 -
Hi Pierre,
How do i add time to above code. Example: 07:00 local time.
Thanks,
0 -
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.
0
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 中文论坛