Skip to main content

Modern, reproducible factor zoo replication engine with transaction costs, decay analysis, and ML ensembles

Project description

Factor Forge

CI Docs PyPI License: MIT

A modern, reproducible factor zoo replication engine for cross-sectional equity research.

Factor Forge takes the academic "factor zoo" — momentum, value, quality, low-volatility, investment, profitability — and makes it runnable, honest, and ML-ready. It handles transaction costs, survivorship bias, look-ahead bias, factor decay, and walk-forward machine learning.

Mission: Let any researcher or student answer "Does this factor still work after costs?" with net-of-cost Sharpe, turnover analysis, and uncertainty-aware ensembles.


Why this matters

  • Quantopian is gone and zipline / pyfolio are unmaintained.
  • Most public factor code reports gross returns, ignores transaction costs, and suffers from look-ahead bias.
  • Factor Forge reports net-of-cost Sharpe, turnover, capacity, and factor decay in a clean, extensible Python package.

What you can do

  • Compute 15+ classic factors with a uniform cross-sectional API.
  • Build decile long/short and long-only portfolios with monthly rebalancing.
  • Apply a transaction-cost and slippage model to every trade.
  • Measure information coefficient (IC), factor decay, turnover, and regime performance.
  • Train a walk-forward LightGBM ensemble that combines factors without peeking.
  • Add conformal prediction intervals for return forecasts.
  • Generate publication-ready plots and an MkDocs-powered docs site.

Quickstart

git clone https://github.com/satyamdas03/factor-forge.git
cd factor-forge
python -m venv .venv
source .venv/bin/activate  # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Or install from PyPI:

pip install factor-forge-quant

Run a backtest on a single factor using cached or Polygon data:

export POLYGON_API_KEY=your_key_here
factor-forge --factor momentum_12_1 --start 2015-01-01 --end 2024-01-01 --top-n 100

Or from Python:

from factor_forge import BacktestEngine, DataLoader
from factor_forge.factors.registry import FactorRegistry

loader = DataLoader(source="polygon", api_key="your_key")
prices = loader.load_eod(["AAPL", "MSFT", "GOOGL"], start="2015-01-01", end="2024-01-01")

registry = FactorRegistry()
registry.load_builtin()
factor = registry.get("momentum_12_1")

engine = BacktestEngine(factor=factor, prices=prices, transaction_cost_bps=10.0)
result = engine.run()
print(result.metrics)

Factor library

Category Factors
Momentum momentum_12_1, momentum_52_high, residual_momentum
Value pe_ratio, pb_ratio
Quality roe, gross_margin, accruals
Low volatility idiosyncratic_volatility, beta, max_drawdown
Investment asset_growth, capex_growth
Profitability gross_profits_to_assets

Each factor is a pure function prices / fundamentals → cross-sectional score. Adding a new factor is one function + one registry entry.


Architecture

factor_forge/
├── data/          # Data sources, loader, cache, survivorship handling
├── factors/       # Factor definitions and registry
├── backtest/      # Portfolio, cost model, decile engine
├── analytics/     # Metrics, IC, decay, turnover, regimes, correlations
├── ml/            # Walk-forward features, LightGBM ensemble, conformal prediction
├── viz/           # Publication-ready plots
├── cli/           # Command-line tools
└── docs/          # MkDocs site + blog

Roadmap

Version Goal Status
v0.1.0 Data pipeline + 5 core factors + decile backtest
v0.2.0 15+ factors + transaction costs + analytics
v0.3.0 Factor decay, turnover, regime analysis
v0.4.0 ML ensemble + conformal prediction
v0.5.0 Dashboard + research report generation 🔲

Documentation

Full documentation, API reference, and research blog are at:

https://satyamdas03.github.io/factor-forge/


Interview talking points

  • "Most retail factor backtests report gross returns. Factor Forge reports net-of-cost Sharpe and turnover-adjusted returns."
  • "I handle delisting and point-in-time fundamentals to avoid look-ahead bias."
  • "I found momentum still works but turnover is high; low-vol is crowded and decayed post-2020."
  • "I combined factors with a walk-forward LightGBM ensemble and added conformal prediction intervals for risk."

License

MIT © Satyam Das

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

factor_forge_quant-0.1.2.tar.gz (35.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

factor_forge_quant-0.1.2-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file factor_forge_quant-0.1.2.tar.gz.

File metadata

  • Download URL: factor_forge_quant-0.1.2.tar.gz
  • Upload date:
  • Size: 35.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for factor_forge_quant-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d1ebf521e5fffd001b4bc200dd3d478e97699440bb40a441692a4a702dd9f08c
MD5 2326b9d67dbaf546412df4af0c2b6165
BLAKE2b-256 b4efc2d5f5b8ec23cf879bb104c0fa140cd98d2ff6d95406898ccbb014752f1a

See more details on using hashes here.

File details

Details for the file factor_forge_quant-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for factor_forge_quant-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3079d0ba0a0933c567e3556bc04247e4637fc2ee9a1fff9722d4e5269acb8ac2
MD5 be6b9276ea35b47967419fc815c19cab
BLAKE2b-256 f8c83823be094a9efb439ee45752780e417e317ada84b9ea61091b864b4d1d9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page