I can get the current list of the S&P constituents using this: ek.get_data('0#.SPX',['TR.CommonName', 'TR.InstrumentIsActive', 'TR.CompanyMarketCap', 'TR.PriceClose']).
But I would like to be able to get the list on any given date that I would pass on to the code. Is there any way to do this? Thank you.
There is, but the depth of historical data depends on the index provider. Try this for the snapshot of the constituents for January 1st, 2016:
tr.get_data(instruments=".SPX", fields=["TR.IndexConstituentRIC","TR.IndexConstituentName"], parameters={'SDate':'2016-01-01'})
I tired this, but It seams that it does not return data before 2014. Is this data not avaalible?
I would suggest calling Thomson Reuters Support Desk with this, they would be able to provide you more asset specific information.
Here's another method that I find to produce much better results:
tr.get_data("0#.SPX(2012-01-01)", ["TR.CompanyName"])
Two reasons.
See the discussion on this thread for more details and alternative ways to retrieve historical index constitutes.