A desktop application for exploring the historical correlations between equity tickers. Enter a
portfolio, download end-of-day prices from Yahoo Finance (via yfinance), and visualise the
correlation matrix as a colour-coded Tkinter canvas.
- Pure-Python correlation engine requiring only the standard library for analysis
- Optional integration with
yfinanceto download daily adjusted closes - Custom Tkinter canvas heatmap with numeric overlays and tabular output
- Supports log or percentage return calculations and enforces simple input validation
python -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activatepip install -r requirements.txt
yfinancepulls inpandasand other dependencies needed for data retrieval. The analytical code itself does not rely on external libraries.
python app.pyEnter ticker symbols (comma or space separated), configure the date range and return calculation, then press Build heatmap. The app fetches daily prices, computes overlapping return series, and displays the resulting correlation matrix both numerically and as a colour map.
A small pytest suite verifies the return and correlation calculations and the colour mapping logic:
pytestCorrelHeatmap/
├── app.py # Tkinter user interface and heatmap renderer
├── requirements.txt # Optional runtime dependencies
├── src/
│ └── correlheatmap/
│ ├── __init__.py
│ ├── analysis.py # Pure Python return/correlation calculations
│ ├── data.py # Optional yfinance data loader
│ └── visualization.py # Colour utilities for the heatmap
└── tests/ # Pytest unit tests
- Network access is required for live data downloads. If you are working offline, you can populate a
PriceHistorydictionary manually and callcompute_correlation_matrixdirectly. - Heatmap colours follow a blue (negative) to red (positive) gradient with white representing zero correlation. Values are clamped to the [-1, 1] interval.
- Tkinter is part of the Python standard library, so no additional GUI framework is required.