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
@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
I hope this can help. NB Historical constituents are not available for all indices.
Thank you Jayson. My apologies. I missed to add. The client only has delayed access for this RIC. Would it matter?
@romerson.gadil I'm not sure - I don't think it should matter as the information is coming from a non-realtime source. Ask the client to try it and see.