ETF constituent movers on a list of dates

Given a list of dates, I want the individual returns for each of the constituents of an ETF (for each of those dates)

Best Answer

  • 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:

    dibetfreturns.gif

    Therefore, a request similar to:

    # obtain constituents at date
    df, err = ek.get_data('RPV',['TR.ETPConstituentRIC','TR.ETPConstituentWeightPercent'],{'SDate': '2017-01-03'})
    # create a list of constituents at date
    list(df['Constituent RIC'])
    # request returns per list
    df, err = ek.get_data(list(df['Constituent RIC']),['TR.TotalReturn','TR.TotalReturn1Wk'],{'SDate': '2017-01-03'})
    df

    Would result in:

    return.gif

    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

Answers

  • @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 = cons

    df

    1636479743314.png


    I would then get the daily returns separately as Zoya has described above. I hope this can help.