Dates generated by get_timeseries function

Hi,
i have problem with dates generated by get_timeseries function
The dates are in format -> year-month-day 00:00:00
If I do this command
ric_stoxx='.STOXX'
stoxx=ek.get_timeseries(ric_stoxx,fields='CLOSE', start_date='2020-01-03')
than the last date (today) is 2021-03-10 00:00:00
This date is not valid for the last day of that time series, because the last day has the latest value, and not value from 00:00:00. The other problem is that in this chart, the values looks really ugly
stoxx_differences=stoxx['CLOSE'].diff()
df = pd.DataFrame({
'Stoxx differences':stoxx_differences['2021-02-14':]
})
ax = df.plot.bar(stacked=True)
pyplot.tight_layout()
pyplot.gcf().set_size_inches(10, 6)
pyplot.axhline(y=0, color="maroon", linewidth=0.7)
pyplot.show()
Please how to repair it, for example how to change the labels to format year-month-day without 00:00:00 ?
Thank you very much
Best Answer
-
Hi @Novotnyja
I am not a Python or Matplotlib expert - and there may better solutions - but the following works for me:
import matplotlib.pyplot as plt
ric_stoxx='.STOXX'
stoxx=ek.get_timeseries(ric_stoxx,fields='CLOSE', start_date='2020-01-03')
stoxx_differences=stoxx['CLOSE'].diff()
df = pd.DataFrame({'Stoxx differences':stoxx_differences['2021-02-14':]})
df.index = pd.to_datetime(df.index).date
ax = df.plot.bar(stacked=True)
plt.tight_layout()
plt.gcf().set_size_inches(10, 6)
plt.axhline(y=0, color="maroon", linewidth=0.7)
plt.show()The extra line being
df.index = pd.to_datetime(df.index).dateIn terms of the last day being wrong, this is because you are probably seeing the current price since 2021-03-10 has not ended yet. I suspect the timestamp of 0:0:0 is superfluous for all days.
So, you could request data for one less day i.e.
stoxx=ek.get_timeseries(ric_stoxx,fields='CLOSE', start_date='2020-01-03', end_date='2021-03-09')
To be absolutely sure, about Content/data issues - you should raise a Content ticket with the Refinitiv Helpdesk -as the moderators on this forum are not generally Content experts.
0
Answers
-
Thank you, your solution works well
0 -
@Novotnyja So the default frequency as you have not specified one is daily. So the Close field will represent the historical closing price for the dates in the series and the last value will be the most recent price. (you can test this during the market hours of the stoxx and the last value ie today does indeed reflect the most recent price). In the daily frequency, the time (hour, min, sec etc) part of the timestamp will not be used.
To drop the time part of the timestamp you can just reformat it in pandas using which just returns a datetime date-only object:
stoxx.index = stoxx.index.date
When you chart this it will not contain the time portion. I hope this can help.
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛