MarketForge — Synthetic Market Data Generator

MarketForge is an open source Python library and CLI that generates synthetic OHLCV market data for forex, crypto and stocks, realistic enough to backtest and stress test trading systems.
- Type: Python package, published on PyPI —
pip install marketforge - Role: sole author
- Timeline: Dec 2025 – Jun 2026 (current version 2.0.0)
- License: MIT
Why
Backtesting needs a lot of market data. Real history is finite and awkward to redistribute, while naive random walks produce data that no strategy can be honestly tested against. MarketForge generates unlimited data instead, reproducing the statistical behaviour that actually matters — and ships a harness that measures whether it did.
How it works
- Correlated heavy-tailed shocks — multivariate Student-t innovations sharing one mixing variable per time step, correlated through Cholesky decomposition, so assets move and crash together
- Volatility dynamics — GJR-GARCH(1,1) with a leverage effect (down moves raise volatility more), Markov regime switching between trend, range, high-volatility and crash states, plus variance-neutral intraday and weekly seasonality
- Candle construction — intrabar High/Low from a Brownian bridge scaled by conditional volatility, so ranges are statistically consistent and High ≥ max(O,C) and Low ≤ min(O,C) hold by construction
- Volume — log-AR(1) process coupling volume to volatility through the Mixture-of-Distributions Hypothesis, with time-of-day patterns
- Anomalies — optional price gaps, fat-tail spikes and multi-candle flash crashes with V-shaped recoveries
- Coverage — 208 preconfigured assets (81 forex pairs, 53 crypto, 74 stocks), generated at one minute and aggregated to m5, m15, m30, H1, H4, D1 and W1
Proving the realism
Version 2.0 was a realism upgrade driven by a measurement harness rather than by eye. marketforge validate scores generated data against per-market target bands for the documented stylized facts of real returns:
| Metric | What it captures |
|---|---|
| Excess kurtosis | heavy tails — extreme moves far more likely than under a Gaussian |
| Volatility clustering | autocorrelation of |returns|, i.e. calm and turbulent periods |
| Leverage effect | negative correlation between returns and next-period volatility |
| Range efficiency | intrabar range relative to candle body |
The screenshots below show the harness passing on generated forex and crypto data, and the charts are plotted from that same data.
Engineering
- Vectorized NumPy/SciPy core, with innovations and volatility models behind pluggable abstractions
- Memory-bounded batch processing with a thread pool — a full synthetic year of one-minute EURUSD data (527k candles across 8 timeframes) generates in about 11 seconds
- Fully reproducible: the same seed produces byte-identical CSV files
- 45 pytest tests covering statistical invariants and stylized facts, typed throughout and checked with mypy
- Published to PyPI automatically by GitHub Actions on every push to
main