Is there way to set a dynamic date for SDate? Rather than the static dates in the code below, I'd like to use the defined week1 and week3 dates.
from datetime import date, timedelta
import eikon as ek
ek.set_app_key('APP KEY')
week1 = (date.today()-timedelta(weeks=1)).strftime("%Y-%m-%d")
week3 = (date.today()-timedelta(weeks=1)).strftime("%Y-%m-%d")
rics = [
'HOc1','HOc2','HOc3','HOc4','HOc5','HOc6',
'HOc7','HOc8','HOc9','HOc10','HOc11','HOc12'
]
fields = [
'TR.ClosePrice.date','TR.ClosePrice',
'TR.ClosePrice(SDate=20200625).date','TR.ClosePrice(SDate=20200625)',
'TR.ClosePrice(SDate=20190301).date','TR.ClosePrice(SDate=20190301)'
]
df, e = ek.get_data(rics,fields)
print(df)
df.plot()