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

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
9 0 0 0

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

eikoneikon-data-apiworkspaceworkspace-data-apirefinitiv-dataplatform-eikonpython
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
20.3k 73 10 20

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).date

In 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.

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.

Thank you, your solution works well :)

Upvotes
6.7k 8 6 7

@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.


1615392933810.png (6.2 KiB)
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.

Click below to post an Idea Post Idea