Pulling historical forward curves

So, it's easy to pull forward curves via get_data. For example:
import eikon as ek
ek.set_app_key(<YOUR APP KEY>)
rics = ['0#CL:']
fields = ['CF_NAME','EXPIR_DATE','CF_CLOSE']
df, err = ek.get_data(rics,fields)
print(df)
Instrument CF_NAME EXPIR_DATE CF_CLOSE
0 CLU2 LIGHT CRUDE SEP2 2022-08-22 91.93
1 CLV2 LIGHT CRUDE OCT2 2022-09-20 91.20
2 CLX2 LIGHT CRUDE NOV2 2022-10-20 90.47
3 CLZ2 LIGHT CRUDE DEC2 2022-11-21 89.68
4 CLF3 LIGHT CRUDE JAN3 2022-12-20 88.90
.. ... ... ... ...
121 CLV32 CL OCT32 2032-09-21 66.10
122 CLX32 CL NOV32 2032-10-20 66.21
123 CLZ32 CL DEC32 2032-11-19 66.22
124 CLF33 CL JAN33 2032-12-20 66.34
125 CLG33 CL FEB33 2033-01-20 66.51
[126 rows x 4 columns]
But, I want to be able to do the same for historical curves. I.e., the same curve from a month ago. Meaning, I run the script and the pull would also show the August 2022 contract (if the script was executed prior to its the Aug expiration in July). I want to also be able to easily pull three months ago, etc. It can be separate scripts...doesn't all have to be in one script.
Is there an easy way to do this?
Best Answer
-
Hi @Corey.Stewart ,
Thank you for your question. Unfortunately, you can't mix fundamental and real data with a chain instrument. However, you can extract instruments from the chain and request historical prices for the individual instrument by introducing a parameter argument as shown below:
rics = df['Instrument'].to_list()
fields = ['TR.CLOSEPRICE']
parameters = {'Frq':'D','SDate': '2022-07-12','EDate': '2022-08-12'}
prices, err = ek.get_data(rics,fields, parameters)
pricesPlease let me know should you have any further questions.
Best regards,
Haykaz
0
Answers
-
TL;DR: I need data for 0#CL: as it was in certain points in history, e.g., 0#CL: on March 1, 2022.0 -
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
- 616 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 中文论坛