Survivorship-bias free constituents using chain RICS?

Hello,

I would like to create portfolio using the constitutents of the S&P500 (as benchmark index). However, the older the period of data extraction, there is a smaller number of constituents on the data frame. I am assuming that the chain RICS contains only up-to-date constituents, and not the historical ones. Is is there an option to get the historical list of constituents with their respective additions and delistings of the index?


df, err = ek.get_data(
    instruments = ['0#.SPX'],
    fields = [
        'TR.ISINCode',
        'TR.PriceClose.date',
        'TR.PriceClose',
    ]
    , parameters={'SDate': '-20Y', 'EDate': '0D','Frq':'Y'}
)


Tagged:

Best Answer

  • Jirapongse
    Jirapongse ✭✭✭✭✭
    Answer ✓

    @ricardo.henriquez

    There is an issue regarding historical data for index constituents and weightings, as mentioned in this thread.

    I checked and found that you are correct. It returns the current constituents.

    Please contact the Eikon support team directly via MyRefinitiv, and ask for the update of <ALERT96> and how to get the historical list of constituents with their respective additions and delistings of the index in the Eikon Excel with the =TR function.

    If the =TR function can be used to get the information, we can use the same parameters with the get_data method.


Answers

  • @Jirapongse I just checked <alert96> and the issue is still going on, with no estimated resolution date.

    So, looking from inspiration in similar threads on this forum, I think I have overcome this issue by doing the following to get the historical constituents each month.

    from datetime import datetime
    from dateutil import rrule
    import time
    # dates
    start_date = datetime(2000, 1, 1)
    end_date = datetime(2022, 1, 1)

    df_concat=pd.DataFrame()
    for dt in rrule.rrule(rrule.MONTHLY, dtstart=start_date, until=end_date):
    dt1=dt.strftime("%Y%m%d")
    df1, err = ek.get_data('0#.SPX({})'.format(dt1), ['TR.RIC','TR.CompanyName'])
    df1['index_date']=dt1
    df_concat = pd.concat([df_concat, df1])
    time.sleep(1)
    df_concat

    While this works for small periods of time (less than a year), I get the following error if I request for 20 years.

    EikonError: Error code 400 | Backend error. 400 Bad Request

    I don't get why this happens since I am timing the request, and the request is relative small.

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @ricardo.henriquez

    I can run it properly. The output is:

    1658724055373.png

    The problem could be the server timeout, as mentioned in this thread.

  • I put the time.sleep after the get_data call and increase sleep till 5 sec. Worked smoothly