Skip to content

Research notes

Crypto rolling correlation: window and sample pitfalls

The same returns give different correlations as the window moves. Reproduce the arithmetic, isolate one shared shock and test the daily return boundary.

Two ivory accordion bands cross through three ceramic hoops with a lime bead against a black background.
Illustration for research notes; examples in this article are educational.

Crypto rolling correlation recalculates the relationship between two return series as a chosen lookback window moves forward. Its value depends on the return interval, daily boundary, lookback, missing pairs and influential observations. Compare a predeclared recent and longer window on synchronized returns, report the valid pair count, and inspect sensitivity before treating a change as evidence of diversification.

A coefficient can change because a relationship changed, because one exceptional day entered the sample, or because an old day left it. The portfolio correlation risk guide connects co-movement to combined exposure. Here the task is narrower: determine how much confidence the construction of a rolling estimate deserves.

Define the return pair before the window

Choose two instruments, their price sources, quote currencies and observation times. Use a common valuation currency, or identify the quote-currency effect separately. For daily simple returns, calculate close[t] / close[t−1] − 1 for each asset over the same endpoints. Comparing price levels asks a different question from comparing returns. Mixing a perpetual mark with a spot last trade also changes what is being measured.

Pearson correlation divides the centered cross-product sum by the square root of the two centered square sums. That measures a linear relationship, as defined in NIST's correlation reference:

For A, calculate Saa by summing (a − mean(a))² across the window.

For B, calculate Sbb by summing (b − mean(b))² across the window.

For each paired return, multiply (a − mean(a)) by (b − mean(b)). Sum those products to get Sab.

Correlation is then Sab divided by sqrt(Saa × Sbb).

Recompute both means inside each window. A four-return window ending today uses today's completed return and the previous three. Tomorrow it drops the oldest pair and adds the new pair. This definition uses equal weights; an exponentially weighted estimate would be a different method.

A value of +1 describes an exact positive linear relationship within the supplied sample; −1 describes an exact negative one. Zero means no measured linear relationship, rather than independence. None of these values supplies an asset's volatility, position size or maximum possible loss.

Eight returns, three defensible answers

Consider these deliberately arranged hypothetical daily simple returns, expressed in percentage points. They are teaching inputs, not observations of any crypto asset:

DayAB
1−2−2
2−1−1
3+1+1
4+2+2
5−2+2
6−1+1
7+1−1
8+2−2

Every subset in the next table has a mean of zero for both assets, making the centered sums easy to reproduce.

SamplePaired returnsSabSaaSbbCorrelation
Earlier days 1–44101010+1.0000
Recent days 5–84−101010−1.0000
All days 1–88020200.0000

At day eight, the recent four-return and longer eight-return estimates disagree even though both calculations are correct. The longer window combines two opposing patterns and reports zero. Calling the pair “uncorrelated” without naming that window would conceal the structure visible in the subsets.

The pooled result is not generally an average of shorter-window correlations. It is zero here because these constructed subsets have matching means and square sums, while their cross-products cancel.

Short windows can reveal recent differences quickly, but a few observations can determine the result. Longer windows provide more historical context while mixing episodes that may no longer resemble current conditions. Neither property identifies one universally best lookback. Four and eight observations are intentionally tiny for arithmetic transparency, not suggested research settings.

One common shock changes both readings

Append a hypothetical ninth day: A falls 12% and B falls 15%. Recalculate using the same trailing window lengths.

Endpoint and windowIncluded daysPairsCorrelation
Day 8, four returns5–84−1.0000
Day 9, four returns6–94+0.9335
Day 8, eight returns1–880.0000
Day 9, eight returns2–98+0.8871

For days two through nine, the means are −1.25 and −1.625 percentage points. The sums become Saa = 147.5, Sbb = 219.875 and Sab = 159.75. Therefore 159.75 / sqrt(147.5 × 219.875) = 0.887068….

Both an old pair leaving and a new pair arriving affect the update. To inspect the ninth day's influence specifically, calculate a separate sensitivity result on the retained days two through eight. Those seven pairs give −0.2963. Label this exclusion and its smaller count; it is not the official eight-return reading.

The shared decline is economically relevant if it is real. Removing it because it makes diversification look worse would erase the very event a risk review needs to examine. Keep valid observations in the primary calculation. Use exclusions to understand influence, and correct or exclude bad data only under a documented quality rule.

A high updated coefficient can therefore be a useful warning without proving a persistent new regime. Inspect the underlying returns and event context before changing a model or position on the strength of the coefficient alone.

A daily return needs an actual clock

“Daily” specifies a duration but leaves the boundary unresolved. A return from midnight to midnight UTC differs from one running from noon to noon UTC. Both assets must use the same endpoints within a comparison.

This matters in actual data interfaces. The Binance Spot kline documentation states that timeZone defaults to UTC and changes the interpretation of kline intervals when supplied. Its startTime and endTime remain UTC. This is a documented venue implementation, not a universal rule for every data provider.

For a transparent hypothetical clock example, take nine consecutive 12-hour log returns, in percentage points, starting at 00:00 UTC:

Half-dayAB
1+10
20+1
3−10
40−1
5+10
60+1
7−10
80−1
9+10

Log returns add across adjacent periods, so summing pairs produces each 24-hour return. The log versus simple returns guide explains the distinction; simple returns require multiplying growth factors instead.

Four 24-hour observationsA's log returnsB's log returnsCorrelation
Midnight boundaries: pairs 1–2, 3–4, 5–6, 7–8+1, −1, +1, −1+1, −1, +1, −1+1.0000
Noon boundaries: pairs 2–3, 4–5, 6–7, 8–9−1, +1, −1, +1+1, −1, +1, −1−1.0000

The underlying half-day sequence is unchanged. The boundaries and edge observations change. These exaggerated patterns demonstrate sensitivity, not what real assets normally do. Merely relabeling a timestamp's displayed timezone would not change returns; re-aggregating prices over different endpoints does.

Count valid pairs, not the label on the chart

A “30-day” label can mean the last 30 rows or observations falling within 30 calendar days. These coincide only under suitable timestamps and data coverage. A full set of 30 consecutive close-to-close returns also needs 31 consecutive closes.

Software may distinguish those definitions. pandas' rolling-window documentation separates integer and time-offset windows and provides min_periods to require an observation count. State these choices instead of accepting a default silently.

The pandas rolling-correlation reference uses complete pairwise observations when values are missing. Consequently, different cells in a multi-asset matrix can use different dates and counts. Save each pair's actual sample; a common-date matrix is a separate construction with its own loss of coverage.

Do not replace missing returns with zero. If a close is absent, the next observed price change may span multiple intended intervals. Recover the missing data or mark affected returns invalid before pairing them. A stale price repeatedly carried forward can also create artificial zero returns.

If either series is constant, the denominator is zero and correlation is undefined. SciPy's Pearson documentation explicitly reports that case. An undefined value must not receive a zero-correlation diversification credit.

Repeated windows are not repeated independent evidence

Adjacent 30-return estimates share 29 pairs. A smooth run of chart points therefore reuses much of the same information. Ten consecutive readings above a threshold are not ten independent confirmations of a relationship.

Dependence can also exist within the return series. The return autocorrelation guide covers that separate diagnostic. Overlapping multi-day returns sampled daily create another form of shared input; the return horizon and sampling step both belong in the record.

Treat uncertainty calculations with the same care. SciPy documents distributional assumptions behind its default Pearson test and uses a Fisher transformation for its default confidence interval. A software-produced interval does not by itself establish that serially dependent, selected or changing market observations satisfy the required model. Confidence in a population correlation is also different from a prediction of the next selloff.

When the question concerns co-movement specifically during benchmark declines, downside beta uses a conditional sample and a different statistic. Report that conditioning and its reduced count rather than treating it as interchangeable with all-period rolling correlation.

Keep a reproducible comparison record

Choose the monitoring purpose before looking for an attractive number. Tie the recent window to the period whose relationship could change your review decision; use a longer window to expose historical differences. For example, a study might predeclare 30 and 90 daily returns with a daily update. Those are illustrative lengths, not recommended settings. Freeze the choices before subsequent observations arrive and retain disagreement as information.

Record fieldWhat to save
InputsInstrument, venue, quote currency, price type and data snapshot
ClockReturn formula, endpoints, timezone, horizon and sampling step
WindowTrailing length, row or calendar interpretation, minimum valid pairs
DiagnosticsPair count, missing dates, constant inputs and influential observations
ComparisonRecent and longer estimates on the declared clock, plus labeled sensitivity checks
DecisionWhat requires review and which exposure rule applies while evidence is uncertain

A correlation change should not suspend a separately written daily loss limit. Review the actual exposure and loss path alongside the statistical result. Before accepting a new reading, reproduce its paired returns, explain which observations entered and left, and check whether the conclusion survives the comparison protocol you wrote in advance.

Keep the context with the example.

Each worked example is illustrative, with its sources and assumptions in the article. Read our editorial standards for authorship, verification and corrections.