A cross-sectional multi-factor model for stock selection: build predictive factors, measure their forecasting power with the Information Coefficient (IC), sort stocks into quantile portfolios, and combine factors into a composite alpha. This is the core workflow of factor / alpha research.
⚠️ Academic / personal research project. Not investment advice.
All factors are computable from price/volume alone (no fundamentals needed) and are standardized cross-sectionally (z-score) each date so they are comparable:
| Factor | Definition | Expected tilt |
|---|---|---|
| Momentum | 12-1 month return (skip last month) | Long winners |
| Volatility | Trailing realized vol | Short high-vol (low-vol anomaly) |
| Short Reversal | Last-month return | Fade recent extremes |
These combine into a composite alpha with signed weights, e.g.
+1.0·Momentum − 0.5·Volatility + 0.3·Reversal.
- Information Coefficient (IC) — per-date Spearman rank correlation between a factor score and the forward return. Its mean and IC IR (mean / std) measure predictive strength and stability. Real-world single-factor ICs are typically small (~0.02–0.06); a monotonic quantile spread matters more than a big single-period number.
- Quantile portfolios — sort stocks into quintiles by score and track each bucket's forward return. A monotonic Q1→Q5 spread is evidence the factor works.
- Long-short return — top-minus-bottom quintile.
Factor Mean IC IC IR Hit Rate
Momentum 0.104 0.66 75%
Volatility 0.003 0.02 51%
Reversal 0.049 0.31 61%
Composite quantile mean forward returns (per 21d):
Q1 0.77 Q2 1.06 Q3 1.80 Q4 1.69 Q5 2.30
Long-short mean: 1.53% per period (~20% annualized, gross)
The monotonic Q1→Q5 increase is the key result: higher composite score -> higher forward return.
- Cross-sectional standardization keeps factors comparable and combinable.
- 12-1 momentum skips the most recent month to avoid contamination by short-term reversal — a standard practitioner correction.
- IC, not just returns — the project judges factors by rank-correlation predictive power, the way factor researchers actually do.
- Results shown are in-sample and gross of costs (stated plainly).
pip install -r requirements.txt
# Synthetic universe (no network)
python examples/run_factor_model.py
# Real universe
python examples/run_factor_model.py --tickers AAPL MSFT GOOG AMZN META NVDA \
--start 2019-01-01 --end 2024-12-31python tests/test_factor_model.pyConfirms z-scores are standardized, momentum shows positive IC on a universe where it carries signal, and the top quantile beats the bottom.
src/
factors.py # factor construction + cross-sectional z-score + combine
evaluation.py # IC, quantile portfolios, long-short, IC summary
data_loader.py # Yahoo! Finance + synthetic universe with real signal
examples/
run_factor_model.py # end-to-end factor study
tests/
test_factor_model.py # standardization + signal-detection checks
- Factor-return attribution via cross-sectional regression (Fama-MacBeth)
- Neutralize factors against sector / size exposures
- Transaction-cost-aware long-short backtest with turnover control