How to chart a rolling correlation between two assets
Quick answer
To chart a rolling correlation, convert both price series to returns, then compute the Pearson correlation over a moving window - in pandas, returns_a.rolling(window).corr(returns_b) - and plot the result as a line through time, bounded between -1 and +1. Pick the window to match your question: around 60 trading days for a tactical view, 252 for a structural one. The line's job is to show when a relationship changed, which a single static correlation hides - as it did when the stock-bond correlation flipped from negative to positive through 2022.
A static correlation number tells you how two assets moved together over one window. A rolling correlation tells you when that relationship changed, which is usually the thing you actually need to know. It is the same Pearson correlation computed again and again over a sliding window, then drawn as a line through time - and it is the honest companion to a correlation matrix heatmap, which collapses the whole period into a single grid and quietly assumes the relationships held steady.
Start with returns, not prices
The first rule is the same one that governs the static matrix: correlate returns, not price levels. Two assets that both trend upward show a high correlation on prices whether or not their day-to-day moves have anything in common, because the trend itself dominates. Convert to returns first, the percentage change from one period to the next, and correlate those. In pandas that is one step ahead of the rolling call: returns = prices.pct_change().dropna().
Compute it over a sliding window
A rolling correlation walks a fixed-length window across the return series, recomputing the Pearson correlation at each step: corr(a[t-N:t], b[t-N:t]) for every t. Each point on the finished line is a correlation measured over the N periods ending on that date. In pandas the whole thing is one expression: returns_a.rolling(window=60).corr(returns_b). The first N-1 points are undefined, because the window is not yet full, so the line starts N periods in.
Because every point is a genuine Pearson correlation, the y-axis is bounded to -1 and +1 by construction. Fix the axis to that full range rather than letting the chart auto-fit; a line that wanders between 0.2 and 0.7 looks alarming on an auto-scaled axis and calm on the correct one. A horizontal line at zero is worth drawing, because the sign of the correlation is often the whole story.
Choose the window deliberately
The window length is the one real judgement call, and it is a trade-off. A short window, 30 or 60 trading days, reacts fast and catches regime changes early, but it is noisy, and a handful of large days can swing it. A long window, 252 days or roughly a calendar year, is stable and structural, but slow: it can take months to register a break that already happened. Many desks plot two windows on the same axis, a fast line and a slow one, and read the divergence between them. State the window in the title or the axis label every time; a rolling correlation with an unstated window is not a finished chart.
A worked example: stocks and bonds
The clearest case is the correlation between equities and long-dated Treasuries, the relationship the classic 60/40 portfolio leans on. For most of the 2000s and 2010s it ran reliably negative: when stocks fell, bonds tended to rise and cushion the drawdown, so a 252-day rolling correlation between the S&P 500 and long Treasuries sat below zero for years at a stretch. Through 2022, as inflation pushed central banks into rapid rate hikes, that line crossed zero and turned firmly positive; stocks and bonds fell together, and the diversification the long-run average promised was not there when it was needed. A single full-sample correlation blends the two regimes into a middling figure that describes neither. Treat these as the documented direction of that shift rather than a live reading, and confirm the current value on your own data before quoting a number.
[QUADESTO-EMBED: rolling correlation of the S&P 500 vs long-dated Treasuries, 60-day and 252-day windows on one axis, y fixed to -1..+1, zero line drawn]
Read it as a regime detector
The reason to keep a rolling correlation on the wall is that it flags when a hedge stops hedging. A pair you rely on to offset each other, two strategies, an asset and its supposed diversifier, a position and its proxy hedge, only does that job while the correlation holds. When the line climbs toward +1 the two are converging into a single bet; when it swings toward -1 they are offsetting harder than you assumed. Neither move is visible in a correlation computed once over the whole history, which is exactly the number most risk reports still show.
Building it in Quadesto
Drop in two or more price or return series and Quadesto computes the rolling correlation on returns, with the axis fixed to -1..+1 and the window shown on the chart, alongside the static correlation heatmap and the drawdown panel that make up a performance pack. Change the window and the line updates; the returns conversion and the empty leading window are handled for you. The free tier embeds it live with a Made with Quadesto credit; Pro (£149 a month) removes the attribution and adds branded themes for client and investor reporting.