Equal weight S&P 500 fund
This project is a Python implementation of a trading algorithm that utilizes equal-weight allocation to the S&P 500 fund. The script uses the IEX Cloud API to obtain the market cap and price of each stock in the S&P 500, and then calculates the number of shares to buy for a given portfolio value.
pandas numpy requests xlsxwriter
Clone the repository Install the dependencies Create an account on IEX Cloud and obtain an API token Create a Secrets.py file in the project directory and assign your API token to IEX_CLOUD_API_TOKEN variable in the file. Run the trading.py script.
Read the sp_500_stocks.csv file to obtain the list of stocks in the S&P 500. Use the IEX Cloud API to obtain the market cap and price of each stock in the S&P 500. Calculate the number of shares to buy for a given portfolio value and equal-weight allocation to each stock. Create an Excel file (RecommendedTrades.xlsx) with the recommended trades. Format the Excel file with custom colors and fonts.
Run the main.py script. Enter the value of your portfolio when prompted. Wait for the script to complete. Check the RecommendedTrades.xlsx file for the recommended trades. Note: The API usage is limited to sandbox mode only. To use the actual API, a paid subscription is required.