S&P 500 Treemap
Inspired by this website, this project creates an easy to digest interactive treemap visualization of the S&P 500’s movement based on it’s daily market data. It’s functions includes:
Fetching a list of S&P 500 stock tickers from Wikipedia
Retrieving relevant financial data using the yFinance API (Stock Tickers, Open and Close Prices, and Market Capitalization)
Processing the data into a format suitable for visualization using Plot.ly Express
Saving this treemap as both an HTML file and a PNG image and sending an email using a Gmail SMTP server
Python Libraries
yfinance: For retrieving stock market data
pandas: For handling data in DataFrame format and parsing HTML tables
plotly.express: For creating the treemap visualization
plotly.io: For saving and exporting the treemap as an image
numpy: For handling numerical operations (though not actively used in the provided code)
time: For managing pauses in execution (used to avoid API rate limits)
kaleido: For exporting Plotly visualizations to images
smtplib: For sending emails via an SMTP server
datetime: For working with date and time data