Bootstrapping time series: why you resample blocks, not days
The bootstrap is the quant’s universal error bar: resample your data with replacement, recompute the statistic, and look at how much it moves. It quietly assumes the data points are independent. Strategy returns often aren’t: good days follow good days. Shuffle them one by one and you destroy that pattern, and the error bars come out much too narrow. Resampling whole blocks of consecutive days fixes most of it.
Shuffling throws away the dependence
Positive autocorrelation means runs: a few good days in a row, then a few bad ones. Over a sample, those runs don’t cancel as quickly as independent days would, so the sample mean is noisier. Step 1 makes that precise. For an AR(1) process with coefficient φ, the autocorrelations are , and the sum gives step 2.
The iid bootstrap draws each day independently from the sample. Every resampled series is a sequence of independent draws, with autocorrelation zero by construction. So the bootstrap distribution of the mean has variance about , and it reports the iid standard error, too small by .
| φ | iid s.e. is too small by |
|---|---|
| 0.1 | 1.11× |
| 0.3 | 1.36× |
| 0.5 | 1.73× |
| 0.8 | 3.00× |
Negative autocorrelation (mean reversion) goes the other way: the iid bootstrap overstates the error.
Resample blocks
The moving-block bootstrap (Künsch, 1989) cuts the series into all overlapping blocks of length b, draws n/b of them with replacement, and glues them end to end. Inside each block the original sequence of days, and so its autocorrelation, is untouched. Only at the joins does the dependence break, and with long enough blocks there are few joins.
The sample: daily returns, AR(1)
Bootstrap s.e. of the mean vs block length
With φ = 0.5, the grey point at block length 1 (the iid bootstrap) sits far below the true standard error. As the blocks get longer, the estimate climbs towards the truth. With very long blocks it gets noisy again, because there are only a few distinct blocks to resample. Try φ near 0 (block length doesn’t matter) and φ = 0.9 (you need long blocks, and even then you get close only on average).
import numpy as np
def block_bootstrap(x, stat, block=15, n_boot=2000, seed=0):
"""Moving-block bootstrap distribution of stat(x)."""
rng = np.random.default_rng(seed)
x = np.asarray(x)
n = len(x)
k = int(np.ceil(n / block))
starts_max = n - block + 1
out = np.empty(n_boot)
for i in range(n_boot):
starts = rng.integers(0, starts_max, size=k)
idx = (starts[:, None] + np.arange(block)).ravel()[:n]
out[i] = stat(x[idx])
return out
# e.g. a confidence interval for an annualised Sharpe ratio from daily returns r:
# sharpe = lambda r: r.mean() / r.std() * np.sqrt(252)
# lo, hi = np.percentile(block_bootstrap(r, sharpe, block=20), [2.5, 97.5])Block length: long enough to keep the memory
Short blocks break dependence; long blocks leave few distinct blocks and add noise. Theory says the best block length for estimating a variance grows like , with a constant set by how persistent the dependence is (Politis and White, 2004, give a data-driven rule; the arch package implements it). Practical rules of thumb:
- Start with b around (8 for 500 days, 13 for 2,500), and check sensitivity: if the answer keeps rising as b grows, the dependence is longer than your blocks.
- Make b longer than any known cycle in the data, such as a monthly rebalancing effect.
- The stationary bootstrap (Politis and Romano, 1994) uses random, geometrically distributed block lengths with mean b. It’s less sensitive to the exact choice and keeps the resampled series stationary.
Where people slip in interviews
- Bootstrapping a backtest day by day. If the strategy’s returns are autocorrelated (trend, carry, slowly changing positions), the confidence interval for its Sharpe is too narrow.
- Overlapping returns. Monthly returns computed every day overlap by 20 days and are strongly autocorrelated. Treating them as independent inflates t-statistics by roughly √20. Use non-overlapping data, Newey–West errors, or blocks.
- Using a block length of 2 and calling it done. Check that the answer has stopped moving as b grows.
- Expecting the bootstrap to fix non-stationarity. Blocks keep short-range dependence; they don’t fix regime changes.
Try these before you open the answer
Warm-upDaily returns follow an AR(1) with φ = 0.3. By what factor does the iid standard error of the mean understate the truth?Show answer
DeriveDerive the AR(1) factor (1 + φ)/(1 − φ) from step 1 for large n.Show answer
, so (ignoring the correction, which vanishes for large n).
SharpeA backtest shows a Sharpe of 1.0 over 4 years with a t-stat of 2. The daily returns have φ = 0.3. What's the corrected t-stat?Show answer
The standard error of the mean is 1.36× bigger, so . No longer significant at 5%.
NegativeA mean-reverting strategy has φ = −0.3. Is the iid bootstrap error too big or too small?Show answer
Too big. , so the true s.e. is 27% smaller than the iid bootstrap says.
OverlapYou compute 21-day returns every day from iid daily returns. What's the correlation between two adjacent overlapping 21-day returns?Show answer
They share 20 of 21 daily returns, so the correlation is .
StretchWhy does the moving-block bootstrap slightly underestimate the variance even with a good block length?Show answer
The joins between blocks are independent, so the resampled series has no dependence across block boundaries: a fraction of about 1/b of the adjacent pairs lose their correlation. Also, observations near the ends of the series appear in fewer blocks. Both effects bias the variance a little low; they shrink as b grows (but noise grows).
The standard-error numbers were checked against 4,000 simulated AR(1) series. The figure re-runs the bootstrap in your browser for each block length.