Skip to content

dennis20413/factor-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multi-Factor Stock Selection Model

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.


🧠 Factors

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.

📏 Evaluation

  • 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.

📊 Example output (synthetic universe)

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.

🛡️ Methodology notes

  • 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).

⚙️ Install & run

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-31

✅ Validation

python tests/test_factor_model.py

Confirms z-scores are standardized, momentum shows positive IC on a universe where it carries signal, and the top quantile beats the bottom.

🗂️ Project layout

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

🔭 Roadmap

  • Factor-return attribution via cross-sectional regression (Fama-MacBeth)
  • Neutralize factors against sector / size exposures
  • Transaction-cost-aware long-short backtest with turnover control

Author: Dennis Chen (陳雲皓) · LinkedIn · GitHub

About

Cross-sectional multi-factor stock selection — momentum/volatility/reversal factors, Information Coefficient evaluation, quantile portfolios, and composite alpha.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages