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?