Package com.quantfinlib.alpha
- Signal generation —
Factors: nine standard factors (MA crossover, contrarian RSI, MACD, Bollinger reversion, mean reversion, 12-1 momentum, value, quality, low volatility) producing raw cross-sectional scores over anAlphaContextpanel; - Evaluation —
SignalEvaluator: rank IC, IR, t-stat, hit rate, turnover, cross-factor exposure — the cheap filter before any backtest; - Validation —
AlphaValidation: walk-forward selection with OOS efficiency, blocked k-fold consistency, Monte Carlo permutation p-values, parameter sensitivity — the overfitting defense; - Execution-aware backtest —
AlphaBacktester: commission, bid-ask spread, slippage and square-root market impact (microstructure.MarketImpactModel), with gross-vs-net cost decomposition; - Portfolio construction —
PortfolioConstruction: z-score sizing with caps, inverse-vol risk budgeting, sector and beta neutralization, mean-variance tilt; - Reporting —
AlphaReport: alpha decay with half-life, OLS factor attribution, drawdown curves, rolling Sharpe, and the shared ratio set frombacktest.PerformanceAnalytics.
All scores/weights flow as double[] aligned with the frozen
AlphaContext.symbols() order; NaN marks "no data" at every
stage. Factors must never read past their evaluation index — the
no-look-ahead contract on AlphaFactor.
Attach a data.PointInTimeUniverse via
AlphaContext.withUniverse(com.quantfinlib.data.PointInTimeUniverse) to make the whole
pipeline survivorship-honest: dead and non-member names score NaN per bar
and never enter ICs, validation, or constructed weights.
Pricing and seasonality: FamaMacBeth
(the cross-sectional premium estimator — what an exposure is WORTH
per period, with time-series t-stats that absorb the cross-sectional
correlation a pooled regression trips over; a significant intercept
means returns your factors do not explain) and
CalendarAnomalies (day-of-week and
turn-of-month profiles WITH significance — most published calendar
anomalies died after publication, and the t-stat is what separates a
tradable seasonal from a data-mined ghost).
-
ClassDescriptionExecution-aware factor backtest: runs a factor through a construction pipeline into weights, holds them between rebalances, and charges the four costs that separate paper alpha from real alpha: Commission — flat bps on traded notional; Bid-ask spread — half-spread bps paid on every trade (crossing the spread once per side); Slippage — additional fixed bps of implementation noise (latency, partial fills, venue fees); Market impact — the size-dependent cost, via the square-root law in
microstructure.MarketImpactModel, with per-symbol ADV and daily vol estimated from the trailing window.Net/gross curves plus the cumulative fraction of equity each cost component consumed — the cost autopsy.Builds target weights from raw scores at a rebalance (the construction hook).The research dataset an alpha factor operates on: an index-aligned panel of price series over a fixed symbol order, with optional fundamentals.A cross-sectional alpha factor: at a bar index, one raw score per symbol, where higher = more attractive to own (buy high scores, sell low).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.OLS attribution: per-bar residual alpha, factor betas, and fit quality.IC per horizon plus the interpolated half-life of the shortest-horizon IC.Validation for alpha factors — the overfitting defense, run before any capital-weighted conclusion is drawn: Walk-forward — pick the best factor variant on a training window by in-sample IC, measure it on the following unseen window, roll forward.Per-block ICs with their dispersion — consistency across regimes.One walk-forward fold: what was chosen, and how it did out of sample.Observed mean IC against its permutation null distribution.IC across the sweep plus the worst adjacent-parameter drop.All folds plus the aggregate in-sample vs out-of-sample comparison.Calendar anomaly profiles — day-of-week and turn-of-month seasonality with the t-statistics that keep them honest.Per-day-of-week profile, indexed Monday = 0 … Sunday = 6.The turn-of-month split, with a Welch t-stat on the difference.The standard alpha factor library — nine signal generators covering the classic technical, factor-investing and defensive families.Fama-MacBeth cross-sectional regression — the standard answer to the question the IC cannot answer: what is a factor exposure WORTH, per period, in return space?Turns raw factor scores into tradeable weight vectors — deliberately a chain of small, composable, pure functions so a construction pipeline reads as what it does: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 attand forward returns over(t, t+horizon], per evaluation date.Mean 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.The evaluation scorecard;SignalEvaluator.Report.format()renders it for humans.