Given a list of dates, I want the individual returns for each of the constituents of an ETF (for each of those dates)
Hello @arun.sharma3,
Reviewing this previous discussion thread may be helpful with the approach to obtaining this result set.
Next I would tweak/tune the approach to your requirements, and Data Item Browser tool can be helpful to look up available Returns for your target ETF constituents and tune the request:
Therefore, a request similar to:
# obtain constituents at datedf, err = ek.get_data('RPV',['TR.ETPConstituentRIC','TR.ETPConstituentWeightPercent'],{'SDate': '2017-01-03'})# create a list of constituents at datelist(df['Constituent RIC'])# request returns per listdf, err = ek.get_data(list(df['Constituent RIC']),['TR.TotalReturn','TR.TotalReturn1Wk'],{'SDate': '2017-01-03'})df
Would result in:
And if you require this for a list of dates you would run the tuned request per each required date to obtain the results for the date.
Hope this information helps
@arun.sharma3 Please see the following:
dates =['2021-11-01','2021-10-01']df = pd.DataFrame()for date in dates: cons, err = ek.get_data(['ISF.L'], ['TR.ETPConstituentRIC.calcdate', 'TR.ETPConstituentRIC', 'TR.ETPConstituentName', 'TR.ETPConstituentPrice'], parameters={'SDate': "'" + date + "'"}) if len(df): df = pd.concat([df, cons], axis=0,ignore_index=True) else: df = consdf
I would then get the daily returns separately as Zoya has described above. I hope this can help.