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.

Best Answer

  • 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,

Answers