I could not download the historical data of constituent companies of S&P 500. Here is my codes.
import lseg.data as ld
import pandas as pd
ld.open_session(key)
target_date = ["2023-03-01", '2023-03-10', '2023-03-20', '2023-03-31']
fields = ['TR.CommonName','TR.Turnover','TR.CompanyMarketCap]
f = pd.ExcelWriter('sp500comp.xlsx')
for i in range(3):
df = ld.get_data(universe='LS&PCOMP0323', fields=fields, parameters={"SDate": target_date[i], "EDate": target_date[i+1]})
df.to_excel(f, i)
f.close()
ld.close_session()