01 — Utilities

Correlation Matrix

Shows which assets move together — as a color-coded heatmap.

Python
·v1.0
  • Yahoo Finance data
  • Heatmap visualization
  • Rolling correlation
  • Combine any assets
DAXS&PEURGBPGoldDAX1.000.920.350.28-0.31S&P0.921.000.300.22-0.28EUR0.350.301.000.870.12GBP0.280.220.871.000.08Gold-0.31-0.280.120.081.00High positive (risk!)Low correlationNegative (hedge)
02 — Why it works

From problem to solution.

01

The Problem

Trading EURUSD and GBPUSD simultaneously doubles your risk without knowing — because both pairs are highly correlated.

02

The Solution

The tool automatically downloads price data and calculates the correlation between any assets as a color-coded heatmap.

03

The Result

A heatmap shows instantly: Green = correlated (risk!), Red = inverse (hedge opportunity). Plus rolling correlation over time.

03 — Use cases

When do I use this?

  • 01

    You trade DAX and S&P500 → the matrix shows 0.92 correlation → you have nearly identical risk on both positions.

  • 02

    Gold vs. stock indices shows -0.3 → Gold works as a hedge in crisis times.

  • 03

    Rolling correlation shows: EUR/USD and GBP/USD were 0.9 correlated 3 months ago, now only 0.4.

04 — Setup

Getting started

  1. 01

    python correlation_matrix.py (with default assets)

  2. 02

    python correlation_matrix.py --symbols ^GDAXI EURUSD=X GC=F

  3. 03

    python correlation_matrix.py --period 6mo --rolling 20

  4. 04

    Heatmap and rolling chart saved as PNG

05 — Technical

Technical Details

Parameters & Settings(3)
  • --symbols

    Yahoo Finance symbols

    DAX, FTSE, S&P, NASDAQ, EUR/USD, GBP/USD, Gold, Oil
  • --period

    Data period

    1y
  • --rolling

    Rolling window (days)

    30
Full Description
The Correlation Matrix calculates the correlation between any trading assets and visualizes them as a heatmap. **Why correlation?** - Avoid double risk (e.g. EURUSD + GBPUSD = highly correlated) - Diversification through low-correlated assets - Hedging opportunities with negative correlation **Features:** - Automatic data download via Yahoo Finance - Correlation matrix with color coding (Red = negative, Green = positive) - Rolling correlation chart shows changes over time - CLI with flexible parameters
Changelog(v1.0)
v1.02026-02
  • +Initial Release
06 — Support

Need help?

Feel free to reach out with questions or issues.

timon-krueger@web.de