Class BlockBootstrap
Why BLOCKS: returns are autocorrelated (vol clusters, trends persist), and resampling single observations (an iid bootstrap) destroys that structure and UNDERSTATES the uncertainty — the classic way to be falsely confident. Blocks of geometric mean length L preserve local dependence; the stationary variant restarts blocks with probability 1/L and wraps circularly, so every resampled path has the full original length. Rule of thumb: L ≈ n^(1/3) (about 10 for a 1,000-day history).
Deterministic per seed (replayable), and honest about what it is
NOT: the bootstrap resamples the history you had — it cannot
manufacture regimes the sample never contained. Pair with
SharpeValidation (multiple-testing haircut) and
AlphaValidation (out-of-sample discipline); this class
quantifies the sampling error that remains even for an honest,
single-trial backtest. Research lane.
-
Method Summary
Modifier and TypeMethodDescriptionstatic double[]One stationary-bootstrap path (circular, geometric blocks).static double[]sharpeSamples(double[] returns, int meanBlockLength, int resamples, int periodsPerYear, long seed) The bootstrap distribution of ANNUALIZED Sharpe, sorted ascending — read percentiles withMathUtils.percentileSorted.
-
Method Details
-
sharpeSamples
public static double[] sharpeSamples(double[] returns, int meanBlockLength, int resamples, int periodsPerYear, long seed) The bootstrap distribution of ANNUALIZED Sharpe, sorted ascending — read percentiles withMathUtils.percentileSorted.- Parameters:
returns- per-period strategy returns, ≥ 50 finitemeanBlockLength- geometric mean block length L, ≥ 1 (1 = iid bootstrap — only for demonstrating why you should not use it)resamples- bootstrap paths, ≥ 100periodsPerYear- annualization (252 for daily)seed- deterministic seed
-
resample
One stationary-bootstrap path (circular, geometric blocks).
-