Constituent list and weight for .SPX using Python API

Raising this query in behalf of the external client Giang Le (User ID giang.le@tgm-au.com) from Tactical Global Management Ltd. He is seeking assistance on how to retrieve constituent list and weight for .SPX using Python API

Best Answer

  • @romerson.gadil please see the code below:

    For current constituents/weightings:

    df, err = ek.get_data('0#.SPX', ['TR.IndexConstituentWeightPercent.date','TR.IndexConstituentWeightPercent'])
    df

    For historical constituents/weightings you need to add a Sdate parameter:

    df, err = ek.get_data('0#.SPX', ['TR.IndexConstituentWeightPercent.date','TR.IndexConstituentWeightPercent'],{'Sdate':'2020-03-12'})   
    df

    image

    I hope this can help. NB Historical constituents are not available for all indices.

Answers

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.