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, interactive HTML research reports, and a Streamlit dashboard.

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

Generate an HTML research report:

ff-report --factor momentum_12_1 --start 2015-01-01 --end 2024-01-01 --output reports

Launch the interactive dashboard:

pip install "factor-forge-quant[dashboard]"
ff-dashboard

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.5.0.tar.gz (42.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.5.0-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: factor_forge_quant-0.5.0.tar.gz
  • Upload date:
  • Size: 42.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.5.0.tar.gz
Algorithm Hash digest
SHA256 8325f885ecc182155e10ab0495dce702669e3ed7e5f551e42177f07668655a1f
MD5 a2543ea14d0b392b9811529154a96abe
BLAKE2b-256 1a8f09448dcdc605dc4c902ed08ff7738c8afc2624a796941e652288e60b036f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for factor_forge_quant-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 058779f67a5ba1ce9a8087901fcf6d5f970b84afb35d76a0d597417f52333933
MD5 65afea5d2cacf452b6456a56ffb93198
BLAKE2b-256 1e5870f54a3d005457b68a5f0f48c14c97a9640aa80902b631a18813adda13b3

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