Finding and dowloading a list of current S&P 500 companies and their respective price data can be tedious at best. Luckily for you, today I’m going to share with you a Python script that I use to construct a database of daily bar data for the current S&P 500 companies.
adjust the open, high and low data using the ratio of the adjusted close to close.
store the complete dataset in a local HDF5 file indexed by industry sector.
You can change the start and end dates using the START and END variables at the top of the scipt.
Recently, I’ve been investigating methods for constructing an S&P 500 dataset that is free of survivorship bias but haven’t succeeded. If you have any ideas or suggestions please leave a comment below or contact me.