Class DrawdownAnalytics
java.lang.Object
com.quantfinlib.backtest.DrawdownAnalytics
DRAWDOWN structure — because "max drawdown 18%" hides the number that
actually fires clients: how LONG the pain lasted. A strategy that loses
18% and recovers in three weeks and one that spends two years under
water have the same max drawdown and completely different survival
odds. Redemptions, risk-committee reviews and career risk are all
functions of drawdown DURATION, not just depth.
The walk: track the running peak; a drawdown episode opens the first
period equity dips below it and closes when equity regains the peak
(recovery) or the series ends (still open — recoveryIndex = -1,
a fact worth surfacing, not hiding: an open drawdown at the end of a
backtest is often the honest state of the strategy today).
- depth — 1 − trough/peak per episode;
- duration — periods from the peak to recovery (or to the last bar for an open episode);
- time under water — the fraction of ALL periods spent below the running peak. A strategy under water 60% of the time is painful to hold even when each individual dip is shallow;
- episodes — the full chronological list, so callers can take the top-k by depth, histogram durations, or line episodes up against market events.
Complements RiskMetrics.maxDrawdown(double[]),
which returns only the max depth; the two agree exactly on it (tested).
Equity must be positive throughout — a ratio-of-peak drawdown is
meaningless through zero or negative equity. Static, deterministic,
research lane.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne peak-to-recovery episode.static final record -
Method Summary
-
Method Details
-
analyze
- Parameters:
equity- equity curve, ≥ 2 points, all finite and > 0
-