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
55 5 8 7

Include current price in hourly prices time series, python API

Hello,


I am using the below to get a time series of prices, with interval being "hour".

df =pd.DataFrame(ek.get_timeseries(ric, start_date=first_date,interval=interval))


My problem is that I am receiving a time series that stop at the last completed hour. For example if it is 6:15 when I run it, the last price will be the price at 6:00. I would like that the time serie includes the current price. In the current example in the perfect output the last price would be the price now, as if it was the price at 7:00.


Is there any solution the include the last price in my hourly time series? Thanks in advance.

eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apitime-series
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.

Upvote
Accepted
25.3k 87 12 25

Hi @emmanuel.chaslin

One of the issues you would face is that the fields returned via realtime streaming request may not be the same as the ones you get for historical data and even when the field names are identical, the context may differ.

for example

dfhourly =pd.DataFrame(ek.get_timeseries('VOD.L', start_date="2020-12-11T00:00:00",interval='hour'))
dfhourly

returns fields

HIGHLOWOPENCLOSECOUNTVOLUME


If I then want to request streaming data snapshot i.e. the values at the time of the call I have to use different field names:

streaming_price = ek.StreamingPrice('VOD.L', fields= ['CF_HIGH','CF_LOW','OPEN_PRC', 'CF_CLOSE', 'ACVOL_1'])
streaming_price.open(False)
dfstream = streaming_price.get_fields()

However, the actual field values may not correlate e,g. CF_HIGH and CF_LOW would be the highest and lowest values of the day - not for the past 15mins or whatever time has elapsed from the final hourly dataframe value. Likewise for ACVOL_1 - this represents Accumulated volume - so again not the same as the hourly VOLUME you get back with the timeseries call.

I think the better approach would be for you to make another get_timeseries call for the 15-minute interval prior to the time when you are making the call e.g.:

dfminutes =pd.DataFrame(ek.get_timeseries('VOD.L', start_date="2020-12-11T10:00:00",end_date="2020-12-11T10:15:00",interval='minute'))

which would return 15 rows of the same field names and you could then, for example, take the highest and lowest value in that 15 minute period for the HIGH , LOW.
You could then take the first OPEN value as the open price for that 15m period and the final CLOSE value as the close for the same period. For the COUNT and VOLUME, you could sum all the 15 rows to get the total count and volume for the same period.

NOTE: I am not a data content expert, the above is a possible programmatic workaround - and may not reflect a correct understanding of what each individual value represents. You may need to raise a content ticket via My.Refinitiv to confirm the above suggestions make sense from a data perspective,

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.

i think it is a good idea indeed, easier to use.

Upvotes
18.2k 21 13 21

Hi @emmanuel.chaslin

For the latest datapoint at the time you run the API call, please see Streaming data request from this tutorial, https://developers.refinitiv.com/en/api-catalog/eikon/eikon-data-api/tutorials

You will need to

1. request the hourly data, regarding your question, until 6:00

2. At 6:15 when you run the API(streaming request or snapshot request) and get the latest data at 6:15, then append this data point to the dataframe from 1.


ahs1.png (108.8 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.

Thanks for the answer, although it is surpring when we extract daily data, the current day is included, with the last value.

Could you please show how to deal with it in an example?

Basically loading a dataframe which has as said the historic hourly close values of the price until last complete hour, and add to that the current price as of next complete hour ?


It would be very helpful, thanks a lot.

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.