Using API to pull the historical index constituents during a period of time

Is there a way to use API to pull the historical index (eg. ASX 200 Index) constituents during a period of time (eg. 1/1/2016-12/31/2016)? I know we can pull on a daily basis by using "= tr.get_data("0#.AXJO(2016-08-09)","TR.CommonName")", but can we do for a period of time? This is the entire reason I am using the API

Best Answer

  • chavalit-jintamalit
    Answer ✓

    Hi @yiyezhou and @charleszhou

    It is not possible to directly retrieve the index on a date range.

    Here is the explanation from @Alex Putkov.

    So basically, you have 2 ways to achieve this:

    1. Loop your code from start_date to end_date and call get_data

    df, e = ek.get_data('0#.SPX(2016-01-01)','TR.RIC') #then keep the data to your local variable
    df, e = ek.get_data('0#.SPX(2016-01-01)','TR.RIC') #then keep the data to your local variable
    ...
    ...
    df, e = ek.get_data('0#.SPX(2016-12-30)','TR.RIC') #then keep the data to your local variable
    df, e = ek.get_data('0#.SPX(2016-12-31)','TR.RIC') #then keep the data to your local variable

    Please note to beware of API call limitation too.

    2. Get the constituent on the start date and get joiner and leaver from start date to end date and apply them locally in your code:

    image


Answers

  • I have the same question here. It will be really helpful if Eikon API can do that. It is a really common function to use in the industry I am working in.