Class SignalEvaluator
java.lang.Object
com.quantfinlib.alpha.SignalEvaluator
Signal evaluation — the metrics that decide whether a factor is worth
constructing a portfolio from, computed before any backtest so
weak signals die cheaply:
- IC (information coefficient) — Spearman rank correlation
between scores at
tand forward returns over(t, t+horizon], per evaluation date. Rank (not Pearson) because factor scores have arbitrary units and fat tails; rank IC is invariant to any monotone transform of the signal. - IR —
mean(IC) / std(IC): signal strength per unit of signal inconsistency, the standard Grinold-Kahn quality number (0.05 mean IC with steady sign beats 0.10 that flips). - t-stat —
mean(IC) / (std(IC)/√n): is the mean IC distinguishable from zero given how many dates we observed. - Hit rate — fraction of (symbol, date) pairs where the score sign called the forward-return sign.
- Turnover — half the L1 change in normalized weights between consecutive evaluation dates: how much trading the signal demands, the denominator of "does the alpha survive costs".
- Factor exposure — mean cross-sectional rank correlation against another factor: a "new" signal that is 0.9 rank-correlated with momentum is momentum.
Evaluation dates step by horizon so forward-return windows
don't overlap — overlapping windows inflate the t-stat through serial
correlation, the classic way factor research fools itself.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordMean forward return per score quantile — the picture behind the IC:meanReturns()[0]is the average forward return of the lowest-scored names, the last entry of the highest-scored, andSignalEvaluator.QuantileReport.spread()is the top-minus-bottom long/short return per period.static final recordThe evaluation scorecard;SignalEvaluator.Report.format()renders it for humans. -
Method Summary
Modifier and TypeMethodDescriptionstatic SignalEvaluator.Reportevaluate(AlphaContext ctx, AlphaFactor factor, int startIndex, int horizon) Evaluates a factor over[startIndex, ctx.bars() − horizon), stepping byhorizon(non-overlapping forward windows).static doublefactorExposure(AlphaContext ctx, AlphaFactor a, AlphaFactor b, int startIndex, int step) Mean cross-sectional rank correlation between two factors' scores — how much of factor B is already inside factor A.quantileReturns(AlphaContext ctx, AlphaFactor factor, int startIndex, int horizon, int quantiles) Buckets each evaluation date's cross-section intoquantilesscore-ranked groups and averages the forward returns per group, over the same non-overlapping date grid asevaluate(AlphaContext, AlphaFactor, int, int): dates step byhorizonfromstartIndex, a NaN score or NaN forward return drops that (symbol, date) pair, and a date with fewer complete pairs thanquantilescontributes to no bucket at all.
-
Method Details
-
evaluate
public static SignalEvaluator.Report evaluate(AlphaContext ctx, AlphaFactor factor, int startIndex, int horizon) Evaluates a factor over[startIndex, ctx.bars() − horizon), stepping byhorizon(non-overlapping forward windows).- Parameters:
horizon- forward-return horizon in bars (also the step)
-
quantileReturns
public static SignalEvaluator.QuantileReport quantileReturns(AlphaContext ctx, AlphaFactor factor, int startIndex, int horizon, int quantiles) Buckets each evaluation date's cross-section intoquantilesscore-ranked groups and averages the forward returns per group, over the same non-overlapping date grid asevaluate(AlphaContext, AlphaFactor, int, int): dates step byhorizonfromstartIndex, a NaN score or NaN forward return drops that (symbol, date) pair, and a date with fewer complete pairs thanquantilescontributes to no bucket at all. Bucketing is by ascending score rank (rank * quantiles / n), so groups are as equal-sized as the cross-section allows; ties are split by input order at the boundary — quantile membership, unlike the rank IC, is not fully tie-invariant, stated.- Parameters:
quantiles- number of buckets, ≥ 2 (5 = quintiles, 10 = deciles)
-
factorExposure
public static double factorExposure(AlphaContext ctx, AlphaFactor a, AlphaFactor b, int startIndex, int step) Mean cross-sectional rank correlation between two factors' scores — how much of factor B is already inside factor A. Above ~0.7 the "new" factor adds little beyond the old one.
-