Modern, reproducible factor zoo replication engine with transaction costs, decay analysis, and ML ensembles
Project description
Factor Forge
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/pyfolioare 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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file factor_forge_quant-0.1.1.tar.gz.
File metadata
- Download URL: factor_forge_quant-0.1.1.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f70adf63f6e4a3232dd4ae366220c52515c1b6b1c4712b63ec56c106618c838
|
|
| MD5 |
3ce08a866eec71f36503bd22e5b15218
|
|
| BLAKE2b-256 |
cf50a7a42fbe611de3f8b85d34b7a51cf351f4c1ef8a3d1110119b0eb779d151
|
File details
Details for the file factor_forge_quant-0.1.1-py3-none-any.whl.
File metadata
- Download URL: factor_forge_quant-0.1.1-py3-none-any.whl
- Upload date:
- Size: 40.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3c2b74d1090aa1ecb70087f480fe70905d59fc972de566331be9e0a8a5452ad
|
|
| MD5 |
581ca2f3d788b2df5f488736db9a1ec4
|
|
| BLAKE2b-256 |
da5d767c9374ef22f3ca944efe57b6ea813bf229fdafff17b25bbff0607eae5c
|