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:

  1. Fetching a list of S&P 500 stock tickers from Wikipedia

  2. Retrieving relevant financial data using the yFinance API (Stock Tickers, Open and Close Prices, and Market Capitalization)

  3. Processing the data into a format suitable for visualization using Plot.ly Express

  4. 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

Previous
Previous

Coffee Shop Rating App

Next
Next

Spotify Tableau Visual