Pearson Correlation Coefficient measures the strength and direction of the linear relationship between two asset return series. It tells you whether two assets tend to move together, opposite each other, or independently — and by how much.
Section 1: Core Mechanics
The Pearson Correlation Coefficient (r) measures how consistently the daily returns of two assets move in the same direction. It ranges from -1.0 (perfect inverse relationship — when one rises, the other falls by the same proportion) to +1.0 (perfect positive relationship — they move identically). A value near 0 means no linear relationship exists between the two return series.
Critical rule: Always calculate Pearson Correlation on returns, not on price levels. Price levels are non-stationary (they trend over time), producing spurious high correlation between any two rising assets regardless of any real relationship.
Formula
Where and are the return series of the two assets, and are their standard deviations, and Cov is their covariance. Expanded:
Use daily log returns for both series: .
Inputs
- Series X: Daily log returns of Asset 1 (e.g., GLD)
- Series Y: Daily log returns of Asset 2 (e.g., SPY)
- Rolling window: Number of bars in the correlation calculation (20, 60, or 252 days)
Parameters
| Parameter | Default | Range | Impact |
|---|---|---|---|
| Rolling window | 60 days | 20–252 days | Shorter = noisier, reacts faster to regime changes; longer = stable but slow to detect shifts |
| Return type | Log returns | Log or simple | Log returns preferred — symmetric, additive, normally distributed |
| Minimum data | 30 bars | 20+ bars | Below 20 bars, r is statistically unreliable |
Output Range
| r Value | Interpretation |
|---|---|
| +0.8 to +1.0 | Highly positively correlated — near-identical movement |
| +0.4 to +0.8 | Moderate positive correlation |
| +0.2 to +0.4 | Weak positive correlation |
| -0.2 to +0.2 | Approximately uncorrelated — genuine diversification |
| -0.4 to -0.2 | Weak negative correlation |
| Below -0.5 | Negative correlation — potential hedging relationship |
| -1.0 | Perfect inverse — theoretical maximum hedge |
Visual Behavior
Plot rolling Pearson Correlation as a line panel beneath the price chart. Stable positive correlations appear as a horizontal band in the +0.6 to +0.8 range. A sharp spike toward +1.0 across an entire portfolio indicates a correlation crisis — all assets moving together, diversification failing. A drop toward 0 or below indicates a genuine decorrelation event — potential pairs trade opportunity.
Section 2: Interpretation & Signals
Reading the Correlation Matrix
For a portfolio of N assets, build an N×N matrix where each cell holds the rolling Pearson r between two assets. Diagonal cells are always 1.0 (self-correlation). Off-diagonal cells below ±0.3 represent genuine diversifiers.
Use the correlation matrix to:
- Identify redundant positions (r > 0.85 — holds two nearly identical assets)
- Find genuine diversifiers (r < 0.2 — adds true portfolio benefit)
- Identify hedging candidates (r < -0.5 — moves opposite your core position)
The Crisis Correlation Collapse — The Most Dangerous Assumption in Finance
This is the most important concept in this lesson.
Pearson Correlation estimated during normal bull market conditions severely underestimates how correlated assets become during a market crisis. In March 2020, assets that historically showed correlations of 0.2 to 0.4 with equities — including gold, corporate bonds, REITs, and commodities — all moved toward r approaching 1.0 simultaneously as forced selling dominated every market.
The same pattern appeared in October 2008, August 2015, and March 2022.
Pairs Trading Signal
Two assets with rolling correlation that has dropped from +0.8 to +0.3 may represent a temporary decorrelation — a pairs trade opportunity. But correlation alone is not sufficient for pairs trading — see lesson 46 on cointegration for the proper statistical test.
Chart — Rolling 60-Day Pearson Correlation: GLD vs SPY
Rolling 60-Day Pearson Correlation — GLD vs SPY (2023)
Section 3: Pass vs. Live — Real-Time Reliability
Rolling Pearson Correlation updates once per day when all included bars close. There is no repaint risk. The 60-day window means the indicator is always reflecting a 3-month trailing period — useful for portfolio construction but slow to react to sudden regime changes. Use a 20-day window if you need faster reaction to regime shifts.
Section 4: Practical Use Cases
Setup: Calculate intraday 20-bar correlation between two assets on 15-minute bars Signal: Correlation dropping from above 0.7 to below 0.3 during the session = potential intraday divergence trade Entry: Long the lagging asset, short the leading asset, once correlation confirms the divergence is real (not just a 1-bar move) Exit: When the lagging asset catches up and correlation returns above 0.6 Key rule: Intraday correlation is very noisy — use 20-bar minimum; filter by volume to confirm the divergence is real
Setup: Calculate 60-day rolling correlation matrix for all holdings quarterly Signal: Any pair dropping below 0.2 = good diversification; any pair rising above 0.85 = redundant position Entry: Add assets that maintain r below 0.3 with existing core holdings; trim redundant positions Exit: Exit one leg when a pair's correlation rises above 0.85 for 10+ consecutive trading days Key rule: Target maximum average portfolio correlation of 0.35 in calm markets
Setup: Build a full correlation matrix monthly; stress-test with 2020-03 historical returns Signal: If stress-test shows portfolio drops more than 20% in a 2020-style scenario, portfolio correlation is too high Entry: Reduce equity concentration; add assets with historically negative stress-period correlation (T-bonds, short-term VIX exposure) Exit: No exit signal per se — this is a portfolio construction tool, not a trade timing tool Key rule: Risk-adjusted return is the goal — adding a low-correlation asset with lower Sharpe often improves the total portfolio Sharpe
Real example: GLD vs. SPY 60-day Pearson Correlation through 2023 ranged from -0.34 to +0.11, averaging approximately -0.10. This confirmed gold as a genuine portfolio diversifier during the year. However, in March 2020, that same pair showed correlation of +0.48 during the peak selloff week — demonstrating that even gold's diversification benefit partially collapsed under forced selling pressure.
Section 5: Pseudo Code
INPUT: series_x[], series_y[], window=60
PROCESS:
Step 1: Calculate daily log returns for both series
ret_x[i] = ln(series_x[i] / series_x[i-1])
ret_y[i] = ln(series_y[i] / series_y[i-1])
Step 2: For each bar i from index (window) to end:
window_x = ret_x[i - window : i]
window_y = ret_y[i - window : i]
Step 3: Calculate Pearson r for the window
mean_x = mean(window_x)
mean_y = mean(window_y)
numerator = sum((xi - mean_x) * (yi - mean_y) for xi, yi in zip(window_x, window_y))
denom_x = sqrt(sum((xi - mean_x)**2 for xi in window_x))
denom_y = sqrt(sum((yi - mean_y)**2 for yi in window_y))
r[i] = numerator / (denom_x * denom_y)
Step 4: (Vectorized alternative)
import numpy as np
r[i] = np.corrcoef(window_x, window_y)[0, 1]
OUTPUT: r[] — rolling Pearson r, range -1.0 to +1.0, NaN for first (window) bars
EDGE CASES:
- If denom_x or denom_y = 0 (zero variance series): return NaN — guard with try/except
- NaN in either series: propagate NaN for that bar
- Require minimum 20 observations for statistical validity
- Always use returns, never raw prices — non-stationary prices produce spurious r near +1.0
Section 6: Parameters & Optimization
Rolling Window Conventions
| Window | Behavior | Best Use |
|---|---|---|
| 20 days | Fast, noisy — reacts to regime shifts within 4 weeks | Pairs trading screening, intraday divergence |
| 60 days | Standard — 3-month rolling correlation | Portfolio construction, asset allocation |
| 130 days | Semi-annual — stable, slow to detect shifts | Institutional risk management |
| 252 days | Annual — near-static, structural correlation | Long-term strategic allocation |
Parameter Impact
| Change | Effect | When to Apply |
|---|---|---|
| Shorten window | Faster detection of decorrelation | Active pairs trading, momentum rotation |
| Lengthen window | More stable, less noisy | Portfolio rebalancing, asset allocation models |
| Use simple returns | Slightly different values, simpler math | Cross-check, but log returns are more rigorous |
Why does using price instead of returns give wrong results?
Two assets both rising 10% per year will show near-perfect r = 0.99 on their price series — even if their day-to-day moves are completely random. Price series are non-stationary (they trend). Pearson Correlation assumes stationarity. Using returns converts prices to a stationary series — making the correlation calculation meaningful.
How many stocks do I need for a properly diversified portfolio?
With average pairwise correlation of 0.3, you need approximately 15–20 stocks to reduce idiosyncratic risk to near zero. With average correlation of 0.6 (typical of sector-concentrated portfolios), you need 30–40 stocks to achieve similar diversification. The correlation structure, not the raw stock count, determines how much diversification you actually get.
Section 7: Synergies & Conflicts
| Works Well With | Avoid Combining With | |
|---|---|---|
| Cointegration Test | Use Pearson Correlation as the first screen — if r is below 0.6, do not bother with cointegration testing for pairs trading | — |
| Beta | Beta and correlation are related — Beta = correlation times (stock sigma / market sigma). Use both together for complete systematic risk picture | — |
| Dynamic Correlation (DCC-GARCH) | Pearson rolling window is the simple version; DCC-GARCH is the sophisticated version — use Pearson for initial screening and DCC for risk management | — |
| VIX | When VIX rises above 30, expect rolling correlations to spike toward 1.0 across all asset classes — weight this in your stress tests | — |
| Price-level correlation | — | Calculating Pearson on price levels, not returns, gives statistically meaningless results — every two upward-trending assets will show high correlation |
| Short windows below 15 bars | — | Fewer than 15 observations make r statistically unreliable — the standard error of r is extremely wide |
| Using r alone for pairs trading | — | Correlation alone does not guarantee mean reversion of the spread — always combine with cointegration testing before trading the pair |
Section 8: Common Mistakes
| Mistake | Root Cause | Solution |
|---|---|---|
| Calculating correlation on price levels | Prices are non-stationary — trending assets show spurious high correlation | Always convert to returns before calculating r |
| Assuming low historical r means low crisis correlation | Normal-market correlation underestimates stress correlation | Stress-test portfolio using 2020-03 and 2008-10 actual return data |
| Using a single correlation estimate | Static correlation misses regime changes | Use rolling correlation with at least two window lengths (20 and 60 days) |
| Treating r = 0.7 as "safe" diversification | Any correlation above 0.5 means meaningful co-movement | Target r below 0.3 for genuine diversification; below 0.0 for hedge-quality diversifiers |
| Confusing Pearson r with R-squared | R-squared = r squared, which removes the sign — tells you variance explained, not direction | Use r for direction; use R-squared only to assess variance explained in regression analysis |
Section 9: Cheat Sheet
USE WHEN: Building a diversified portfolio, screening for pairs trading candidates, stress-testing your correlation assumptions, identifying redundant positions
AVOID WHEN: Looking for entry/exit timing signals — correlation is a portfolio construction tool, not a trade trigger
ENTRY SIGNAL: Add assets with rolling 60-day r below 0.2 vs. existing holdings; screen pairs candidates at r above 0.7 (then confirm with cointegration)
EXIT SIGNAL: Trim or eliminate one position when 60-day rolling r between two holdings stays above 0.85 for 10+ days (redundant exposure)
PARAMETERS: 60-day window for portfolio construction; 20-day window for pairs screening; always use daily log returns
CONFLUENCE: Combine with Beta (systematic risk), VIX (regime filter), and cointegration testing (for pairs trades)
RISK: Correlation assumptions from calm markets fail during crises — always run a 2020-03 stress scenario on your correlation matrix
BEST TIMEFRAME: Daily bars for calculation; apply at portfolio level across all positions