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
-
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'))
dfhourlyreturns fields
HIGHLOWOPENCLOSECOUNTVOLUMEIf 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,
1
Answers
-
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.
0 -
Thanks for the answer, although it is surpring when we extract daily data, the current day is included, with the last value.
0 -
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.
0 -
i think it is a good idea indeed, easier to use.
0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 162 App Studio
- 4 Block Chain
- 5 Bot Platform
- 17 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
- 370 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 中文论坛