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 (
lagIcProfile(AlphaContext, AlphaFactor, int, int)): IC of the scores attagainst the single-bar return over(t+h−1, t+h], forh = 1..H, with an exponential fitIC(h) = IC₀·exp(−(h−1)/τ). This is the curve that says how fast the information is used up and so bounds the rebalance cadence. The signal's own rank autocorrelation at each lag is reported beside it (turnover is roughly1 − autocorrelation). - Holding-period IC (
decayProfile(AlphaContext, AlphaFactor, int, int[])): IC against the cumulative return(t, t+h]. For a slow signal this usually rises and plateaus, so it is not a decay curve; it answers "what is the IC if I hold for h bars". - Factor attribution (
attribute(double[], double[][], List)): OLS of portfolio returns on factor return streams with classical and Newey-West standard errors;FactorReturnsbuilds the streams from the library's own factors. - Curves and ratios: cumulative return, drawdown series, and
the ratio set reused from
backtest.PerformanceAnalytics. - Rolling metrics: the windowed Sharpe.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOLS attribution with standard errors.static final classMean IC per cumulative horizon, plus the horizon where it first falls below half the shortest-horizon value.static final classLagged-return IC profile with its exponential fit. -
Method Summary
Modifier and TypeMethodDescriptionstatic AlphaReport.Attributionattribute(double[], double[][], List, int)with the Andrews (1991) automatic lag picked on the portfolio returns.static AlphaReport.Attributionattribute(double[] portfolioReturns, double[][] factorReturns, List<String> factorNames, int hacLag) Regresses portfolio returns on factor return streams with an intercept,r_p = α + Σ βᵢ·fᵢ + ε, by Householder QR (Ols).static StringCost decomposition of a backtest: each drag as a fraction of equity and as a share of the total, with mean turnover and tracking gap.static AlphaReport.DecaydecayProfile(AlphaContext ctx, AlphaFactor factor, int startIndex, int[] horizons) Mean IC against cumulative forward returns(t, t+h]at each horizon (non-overlapping grid per horizon).static double[]drawdownCurve(double[] equity) Drawdown series: fraction below the running peak (0 at new highs).static double[]Mean book exposure over a traced run, per bar:[gross Σ|w|, net Σw, long Σw⁺, short Σw⁻, names held].static StringformatIcTable(AlphaContext ctx, List<AlphaFactor> factors, int startIndex, int[] horizons) icTable(AlphaContext, List, int, int[])as plain text, one row per factor.static double[][]icTable(AlphaContext ctx, List<AlphaFactor> factors, int startIndex, int[] horizons) Mean IC of each factor at each forward horizon ([factor][horizon]), the same statistic asdecayProfile(AlphaContext, AlphaFactor, int, int[])for one factor.static AlphaReport.LagDecaylagIcProfile(AlphaContext ctx, AlphaFactor factor, int startIndex, int maxLag) IC of the scores attagainst the one-bar return over(t+h−1, t+h]forh = 1..maxLag, averaged over every bartfromstartIndexwith the whole window in sample, then fitted by least squares toIC(h) = IC₀·exp(−(h−1)/τ)(for fixed τ the optimal IC₀ is closed-form; τ is found by golden-section search onlog τover [0.05, 10⁵] bars, and reported as+∞when the best fit sits at the upper bound).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) Mean IC against cumulative forward returns(t, t+h]at each horizon (non-overlapping grid per horizon).halfLifeBarsis the first horizon, linearly interpolated, where the IC drops below half its shortest-horizon value,+∞if it never does. For a decay curve uselagIcProfile(AlphaContext, AlphaFactor, int, int).- Parameters:
horizons- ascending forward horizons in bars
-
lagIcProfile
public static AlphaReport.LagDecay lagIcProfile(AlphaContext ctx, AlphaFactor factor, int startIndex, int maxLag) IC of the scores attagainst the one-bar return over(t+h−1, t+h]forh = 1..maxLag, averaged over every bartfromstartIndexwith the whole window in sample, then fitted by least squares toIC(h) = IC₀·exp(−(h−1)/τ)(for fixed τ the optimal IC₀ is closed-form; τ is found by golden-section search onlog τover [0.05, 10⁵] bars, and reported as+∞when the best fit sits at the upper bound). -
attribute
public static AlphaReport.Attribution attribute(double[] portfolioReturns, double[][] factorReturns, List<String> factorNames) attribute(double[], double[][], List, int)with the Andrews (1991) automatic lag picked on the portfolio returns. -
attribute
public static AlphaReport.Attribution attribute(double[] portfolioReturns, double[][] factorReturns, List<String> factorNames, int hacLag) Regresses portfolio returns on factor return streams with an intercept,r_p = α + Σ βᵢ·fᵢ + ε, by Householder QR (Ols). The intercept is the residual alpha.- Parameters:
portfolioReturns- per-bar portfolio returnsfactorReturns- one per-bar return stream per factor, alignedhacLag- Bartlett lag for the Newey-West errors
-
icTable
public static double[][] icTable(AlphaContext ctx, List<AlphaFactor> factors, int startIndex, int[] horizons) Mean IC of each factor at each forward horizon ([factor][horizon]), the same statistic asdecayProfile(AlphaContext, AlphaFactor, int, int[])for one factor. -
formatIcTable
public static String formatIcTable(AlphaContext ctx, List<AlphaFactor> factors, int startIndex, int[] horizons) icTable(AlphaContext, List, int, int[])as plain text, one row per factor. -
costBreakdown
Cost decomposition of a backtest: each drag as a fraction of equity and as a share of the total, with mean turnover and tracking gap. -
exposureSummary
Mean book exposure over a traced run, per bar:[gross Σ|w|, net Σw, long Σw⁺, short Σw⁻, names held]. -
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). A full-sample rolling window therefore 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.
-