Package com.quantfinlib.alpha


@NullMarked package com.quantfinlib.alpha
Cross-sectional alpha research: signal generation, evaluation, validation, execution-aware backtesting, portfolio construction and reporting, each a separate step.
  1. Signal generation: Factors (MA crossover, contrarian RSI, MACD, Bollinger reversion, mean reversion, 12-1 momentum, value, quality, low volatility) over an AlphaContext panel, with per-date winsorise, z-score and sector-neutralise decorators. Value and quality need point-in-time fundamentals (FundamentalsHistory); a static snapshot is refused for historical bars.
  2. Evaluation: SignalEvaluator: rank IC at every bar with Newey-West t-stats and IC autocorrelation, demeaned hit rate, turnover, quantile spreads, cross-factor exposure.
  3. Validation: AlphaValidation: walk-forward selection with observation-weighted folds and a best-of-N haircut, blocked k-fold consistency, permutation nulls (cross-sectional label permutation by default; circular shift and date permutation as diagnostics), parameter sensitivity.
  4. Execution-aware backtest: AlphaBacktester: next-open fills by default, weights that drift between trades, commission, spread, slippage and square-root impact, participation caps with carry-over, financing, and terminal events for held names.
  5. Portfolio construction: PortfolioConstruction (dollar-neutral z-score books with water-filling caps, inverse-vol budgeting, joint sector/beta/dollar neutralisation, mean-variance tilt) and TurnoverAwareOptimizer (alpha, risk, L1 turnover penalty, boxes, trade limits and neutrality equalities, solved by ADMM).
  6. Reporting: AlphaReport: alpha decay on lagged one-bar returns with an exponential fit, holding-period IC, OLS attribution with Newey-West errors on FactorReturns streams, drawdown curves, rolling Sharpe.

All scores and weights flow as double[] aligned with the sorted AlphaContext.symbols(); NaN marks "no data" at every stage. Factors must never read past their evaluation index. Attach a data.PointInTimeUniverse via AlphaContext.withUniverse(PointInTimeUniverse): non-members score NaN, and forward returns and held positions earn delisting and merger proceeds instead of forward-filled ghost bars.

Pricing and seasonality: FamaMacBeth (cross-sectional premia with Newey-West errors on the premium series, optional per-period standardisation, QR solves) and CalendarAnomalies (day-of-week and turn-of-month profiles with HAC t-stats and Holm-corrected flags). Shared statistics: NeweyWest, Ols.