How can I bulk download the historical daily stock returns for all constituents of .SPX, including both current and former members, from the beginning of 1998 to the end of 2025? So for example, if stock X was a member of .SPX from 2000 but left it in 2008 must be included in the list, showing the daily return from 2000 to 2008 only.
I also want to include their sector names and RICs.
P.s. I have tried the Python package with the API generated by APPKEY + I have tried formulas on Excel but it gives me some errors.