Quant techniques · resampling

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.

1Var(xˉ)=σ2n(1+2∑k≥1(1−kn)ρk)\mathrm{Var}(\bar x) = \frac{\sigma^2}{n}\Big(1 + 2\sum_{k\ge1}\big(1 - \tfrac kn\big)\rho_k\Big) The variance of a sample mean with autocorrelations ρ_k. The iid formula keeps only the 1.
2AR(1):Var(xˉ)≈σ2n⋅1+ϕ1−ϕ\text{AR(1)}: \quad \mathrm{Var}(\bar x) \approx \frac{\sigma^2}{n}\cdot\frac{1+\phi}{1-\phi} With φ = 0.5 the variance triples: the iid bootstrap understates the standard error by a factor of √3 ≈ 1.73.
3Moving blocks: draw blocks of b consecutive days, glue, repeat Dependence inside each block is kept. Only the joins between blocks are artificial.
4b∝n1/3b \propto n^{1/3} The rate for the optimal block length when estimating a variance; the constant grows with the strength of the autocorrelation.
The problem

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 ϕk\phi^k, 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 σ2/n\sigma^2/n, and it reports the iid standard error, too small by (1+ϕ)/(1−ϕ)\sqrt{(1+\phi)/(1-\phi)}.

φiid s.e. is too small by
0.11.11×
0.31.36×
0.51.73×
0.83.00×

Negative autocorrelation (mean reversion) goes the other way: the iid bootstrap overstates the error.

The fix

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.

autocorrelation φ

The sample: daily returns, AR(1)

Bootstrap s.e. of the mean vs block length

true s.e. of the meaniid bootstrap (block length 1)moving-block bootstrap
–true s.e. of the mean
–iid bootstrap s.e.
–block bootstrap s.e., blocks of 15
–how much iid understates, √((1+φ)/(1−φ))

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])
Choosing b

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 n1/3n^{1/3}, 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 n1/3n^{1/3} (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.
Practice

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
1.30.7≈1.36\sqrt{\frac{1.3}{0.7}} \approx 1.36
DeriveDerive the AR(1) factor (1 + φ)/(1 − φ) from step 1 for large n.
Show answer

ρk=ϕk\rho_k = \phi^k, so 1+2∑k≥1ϕk=1+2ϕ1−ϕ=1+ϕ1−ϕ1 + 2\sum_{k\ge1}\phi^k = 1 + \frac{2\phi}{1-\phi} = \frac{1 + \phi}{1 - \phi} (ignoring the k/nk/n 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 t≈2/1.36≈1.47t \approx 2/1.36 \approx 1.47. 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. 0.7/1.3≈0.73\sqrt{0.7/1.3} \approx 0.73, 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 20/21≈0.9520/21 \approx 0.95.

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.