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
-
Thanks, but I already have created something like this with continuous (CLc1, CLc2...) contracts. There's no way to pull a chain like 0#CL: when the contracts were different? I.e., last month the front contract would have been August. I'm assuming I could pull history on individual contracts (CLK1, for example), but is not very useful as this script will be used continuously and needs to update.
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 -
Thank you.0
Categories
- All Categories
- 6 AHS
- 39 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 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 中文论坛