Class AlphaReport
java.lang.Object
com.quantfinlib.alpha.AlphaReport
Alpha reporting — the diagnostics that explain a factor's P&L rather
than just totalling it:
- Alpha decay — mean IC as a function of the forward horizon.
A signal predictive at 1 day but dead at 5 needs fast, expensive
trading; the
halfLifeestimate says how long the edge survives, which bounds the viable rebalance cadence. - Factor attribution — OLS of portfolio returns on factor return streams: how much of the "alpha" is just repackaged momentum/value beta, and what residual (true) alpha remains.
- Curves and ratios — cumulative return, drawdown series, and
the full ratio set (Sharpe, Sortino, Calmar, CAGR, max drawdown)
reused verbatim from
backtest.PerformanceAnalytics, so alpha reports and strategy backtests can never disagree on a definition. - Rolling metrics — the windowed Sharpe that shows whether performance is steady or one lucky year.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOLS attribution: per-bar residual alpha, factor betas, and fit quality.static final recordIC per horizon plus the interpolated half-life of the shortest-horizon IC. -
Method Summary
Modifier and TypeMethodDescriptionstatic AlphaReport.AttributionRegresses portfolio returns on factor return streams (with an intercept) via the normal equations:r_p = α + Σ βᵢ·fᵢ + ε.static AlphaReport.DecaydecayProfile(AlphaContext ctx, AlphaFactor factor, int startIndex, int[] horizons) Evaluates the factor's mean IC at each horizon.static double[]drawdownCurve(double[] equity) Drawdown series: fraction below the running peak (0 at new highs).static double[]returnsOf(double[] equity) Per-bar simple returns of an equity curve — the input to attribution/rolling.static double[]rollingSharpe(double[] returns, int window, int periodsPerYear) Rolling annualized Sharpe over a trailing window of per-bar returns; NaN until the window fills.static PerformanceMetricssummarize(double[] equity, int periodsPerYear) The full ratio set on an equity curve — Sharpe, Sortino, Calmar, CAGR, max drawdown — computed by the same engine the backtesters use, so definitions never fork between research and backtest reports.
-
Method Details
-
decayProfile
public static AlphaReport.Decay decayProfile(AlphaContext ctx, AlphaFactor factor, int startIndex, int[] horizons) Evaluates the factor's mean IC at each horizon. The half-life is the first horizon (linearly interpolated) where the IC falls below half of its shortest-horizon value;+∞when it never does within the tested range — the honest answer for slow signals.- Parameters:
horizons- ascending forward horizons in bars
-
attribute
public static AlphaReport.Attribution attribute(double[] portfolioReturns, double[][] factorReturns, List<String> factorNames) Regresses portfolio returns on factor return streams (with an intercept) via the normal equations:r_p = α + Σ βᵢ·fᵢ + ε. The intercept is the residual alpha — what survives after the known factors take their share. Keep the factor count far below the bar count; the normal equations of collinear factors are a data problem, not a solver problem.- Parameters:
portfolioReturns- per-bar portfolio returnsfactorReturns- one per-bar return stream per factor, aligned
-
returnsOf
public static double[] returnsOf(double[] equity) Per-bar simple returns of an equity curve — the input to attribution/rolling. -
drawdownCurve
public static double[] drawdownCurve(double[] equity) Drawdown series: fraction below the running peak (0 at new highs). Guardspeak > 0exactly likerisk.RiskMetrics.maxDrawdownsomin(drawdownCurve)and the headline max-drawdown metric can never disagree on a curve that touches zero. -
rollingSharpe
public static double[] rollingSharpe(double[] returns, int window, int periodsPerYear) Rolling annualized Sharpe over a trailing window of per-bar returns; NaN until the window fills. The steadiness plot: a flat positive line is a strategy, a single spike is an anecdote.Uses the SAMPLE standard deviation (n−1) — the same definition as
risk.RiskMetrics.sharpeRatiobehindsummarize(double[], int)— so a full-sample rolling window reproduces the headline Sharpe exactly rather than differing by√(n/(n−1)). -
summarize
The full ratio set on an equity curve — Sharpe, Sortino, Calmar, CAGR, max drawdown — computed by the same engine the backtesters use, so definitions never fork between research and backtest reports.
-