mirror of
https://github.com/manifoldbt/manifoldbt.git
synced 2026-08-24 14:38:04 +00:00
53a32b361d9969fe537071e075f823b1ed44c1bb
ManifoldBT
Rust-powered backtesting engine for quantitative research
Website · Documentation · Examples
ManifoldBT compiles Python strategy definitions into an optimized Rust expression graph. Write strategies in a fluent Python DSL — execute them on a vectorized Rust engine.
Why ManifoldBT
- Fast — 500K bars in ~26ms. 161x faster than vectorbt, 1000x+ faster than backtrader.
- Expressive — fluent DSL with 30+ indicators, conditional logic, cross-asset references
- Rigorous — Monte Carlo, walk-forward, parameter sweeps, lookahead detection, exposure diagnostics
- Portable —
pip install, no Rust toolchain needed. Works on Python 3.9+.
Installation
pip install manifoldbt
With all extras (plotting, pandas, polars):
pip install manifoldbt[all]
Quick Start
import manifoldbt as mbt
from manifoldbt.indicators import close, ema
from manifoldbt.helpers import time_range, Interval, Slippage
fast = ema(close, 12)
slow = ema(close, 26)
strategy = (
mbt.Strategy.create("ema_crossover")
.signal("fast", fast)
.signal("slow", slow)
.signal("signal", mbt.when(fast > slow, mbt.lit(1.0), mbt.lit(-1.0)))
.size(mbt.col("signal") * mbt.lit(0.25))
)
start, end = time_range("2022-01-01", "2025-01-01")
config = mbt.BacktestConfig(
universe=[1],
time_range_start=start,
time_range_end=end,
bar_interval=Interval.hours(12),
initial_capital=10_000,
execution=mbt.ExecutionConfig(allow_short=True, max_position_pct=0.5),
fees=mbt.FeeConfig.binance_perps(),
slippage=Slippage.fixed_bps(2),
warmup_bars=30,
)
store = mbt.DataStore(data_root="data", metadata_db="metadata/metadata.sqlite")
result = mbt.run(strategy, config, store)
print(result.summary())
Examples
| # | Example | What it shows |
|---|---|---|
| 00 | Template | Minimal starting point |
| 01 | Trend Following | EMA crossover, volume filter, stop-loss |
| 02 | Mean Reversion | EMA crossover with parameter sweep |
| 03 | Multi-Asset Momentum | Cross-asset signals |
| 04 | Linear Regression | Regression-based signal |
| 05 | Statistical Arbitrage | Pairs trading, spread z-score |
| 06 | Full Visualization | Tearsheet and charts |
| 07 | Walk-Forward | Out-of-sample validation |
| 08 | 2D Sweep | Parameter grid heatmap |
| 09 | 3D Surface | Parameter surface plot |
| 10 | Monte Carlo | Permutation-based robustness |
| 11 | Portfolio | Multi-strategy portfolio |
Performance
EMA(12/26) + RSI(14) on 500K synthetic 1-min bars (median of 5 runs):
| Engine | Time | vs ManifoldBT |
|---|---|---|
| ManifoldBT (Rust) | 26 ms | 1x |
| vectorbt (NumPy) | 4,094 ms | 161x slower |
| backtrader (Python) | — | ~1000x slower |
Reproduce: python benchmarks/bench_vs_competitors.py --rows 500000 --runs 5
Documentation
Full API reference, indicator list, configuration guide, and best practices:
www.manifoldbt.com/docs/documentation.html
Community vs Pro
| Community | Pro | |
|---|---|---|
| Output resolution | Daily | 1m, 5m, 15m, 1h |
| Monte Carlo | 1K sims | Unlimited |
| Walk-Forward | - | Anchored + Rolling |
| Parameter Stability | - | Yes |
| Crypto connectors (Binance, Hyperliquid) | Yes | Yes |
| Databento & Massive connectors | - | Yes |
| Safety checks (lookahead, exposure) | - | Yes |
| Tearsheets & export | - | Yes |
License
MIT
Languages
Python
100%