Nicodème Westphalen
Products2024

Stock Correlation Web App

Interactive Streamlit application that computes and visualizes correlation matrices between financial assets using Yahoo Finance data.

Overview

The Stock Correlation Web App is an interactive financial analysis tool that allows users to explore the correlation between different assets.
Users can input any set of stock ticker symbols, select a time range, and instantly generate a correlation matrix and heatmap visualization.

The goal of the project was to build a lightweight interface for quickly understanding relationships between financial instruments, which is particularly useful for portfolio diversification and risk analysis.

Features

  • Dynamic ticker input (any Yahoo Finance symbol)
  • User-defined time range for analysis
  • Automatic data retrieval from Yahoo Finance
  • Correlation matrix generation
  • Heatmap visualization for intuitive interpretation

Methodology

The application retrieves historical stock data using the yfinance API.
Closing prices are extracted and used to compute a Pearson correlation matrix between all selected assets.

The resulting matrix is cleaned, rounded for readability, and visualized using a Seaborn heatmap, which highlights both positive and negative relationships between assets.

Interface

The app is built with Streamlit, allowing users to interactively:

  • Enter a list of ticker symbols
  • Select a start and end date
  • Generate a correlation matrix instantly

Results are displayed as both a numerical dataframe and a visual heatmap, making it easier to identify clusters of correlated assets.

Live app

Streamlit app — correlation matrix from historical price data.

Screenshots

Stock Correlation app start page

Start page: ticker input and date range selection.

Stock Correlation app result page

Result: correlation matrix visualization for selected tickers.

Key Takeaways

  • Correlation analysis is a simple but powerful tool for portfolio diversification.
  • Visual heatmaps make financial relationships easier to interpret.
  • Streamlit enables rapid prototyping of data applications with minimal frontend work.