Skip to main content

ManifoldBT logo

ManifoldBT
Rust-powered backtesting engine for quantitative research

Discord

Website · Documentation · Examples


ManifoldBT is a Python backtesting library with a Rust core. Strategies are written in a fluent Python DSL, compiled to a vectorized Rust expression graph, then run through a sequential fill simulation with realistic fees, slippage, funding and look-ahead protection. Vectorized speed with event-driven execution realism.

Why ManifoldBT

  • Fast: 10M bars in 317 ms. 78x faster than vectorbt, 308x once you also want drawdown and Sharpe, ~3,500x faster than backtrader. Measured in public CI, every run linked.
  • 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              # engine only: backtests, sweeps, metrics
pip install manifoldbt[plot]        # + interactive charts and native windows (show=True)
pip install manifoldbt[all]         # everything: plots, windows, PNG export, pandas/polars
pip install manifoldbt[gpu]         # + NVIDIA runtime compiler, for device="cuda" (Pro)

The base install stays light (no browser, no GUI) for scripts, servers and CI. [plot] adds plotly and a native window backend; [all] also pulls kaleido for static PNG/SVG export (which bundles a headless Chromium).

The Linux and Windows x86_64 wheels already carry the CUDA kernels, so [gpu] only adds the NVIDIA runtime compiler (~180 MB) that compiles them on your machine. Skip it if you already have a CUDA toolkit installed. An NVIDIA driver is required, and GPU acceleration is a Pro feature; everything else runs at full speed on the CPU.

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.ingest(provider="binance", symbol="BTCUSDT", symbol_id=1,
                   start="2022-01-01T00:00:00Z", end="2025-01-01T00:00:00Z", interval="1h")
result = mbt.run(strategy, config, store)
print(result.summary())

Loading data

Bring your own data, or pull it from a built-in connector. Both return a DataStore ready for mbt.run(...).

CSV, free on all tiers, auto-detects standard / MetaTrader 4 / MetaTrader 5:

store = mbt.import_csv("EURUSD_1m.csv", symbol="EURUSD", symbol_id=1,
                       interval="1m", asset_class="forex")

Market data connectors: Binance, Bybit, Hyperliquid, dYdX, Bitstamp, Yahoo Finance (free); Databento, Massive (Pro):

store = mbt.ingest(provider="binance", symbol="BTCUSDT", symbol_id=1,
                   start="2024-01-01T00:00:00Z", end="2025-01-01T00:00:00Z")

Yahoo Finance covers stocks, ETFs, indices (^GSPC), FX (EURUSD=X), futures (ES=F) and crypto (BTC-USD) without an API key. Prices are dividend-adjusted, like yfinance's auto_adjust=True; pass dataset="raw" for unadjusted quotes. Yahoo's own history limits apply: 1m over the last 30 days, 1h over ~2 years, daily back to the listing date.

store = mbt.ingest(provider="yahoo", symbol="AAPL", symbol_id=1, interval="1d",
                   asset_class="equity",
                   start="2015-01-01T00:00:00Z", end="2026-01-01T00:00:00Z")

Or from the CLI:

manifoldbt import-csv data.csv --symbol EURUSD --symbol-id 1 --interval 1m
manifoldbt ingest --provider binance --symbol BTCUSDT --symbol-id 1 --start ... --end ...

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
12 Diagnostics Lookahead & exposure safety checks
13 Stochastic Simulation SDE path simulation (GBM, Heston, …)
14 Multi-Timeframe Combining signals across timeframes
15 Cross-Exchange Signal on one venue, execute on another
16 Exogenous Data External series (e.g. hashrate) as a signal
17 Per-Venue Fees Per-venue funding & borrow costs
18 CSV Import Load OHLCV from CSV (standard / MT4 / MT5)

Performance

Every number below comes from a benchmark that runs in public CI on a standard GitHub runner, and links back to the run that produced it. It installs each engine from PyPI the way a user would, generates its own data, checks that the engines produced the same result, and only then reports how long each took: a workload they disagree on gets no published timing at all.

Latest run: #11 ran on Linux x86_64, 4 vCPU, Python 3.12, manifoldbt 0.17.3 / vectorbt 0.28.4 / raptorbt 0.9.0, 3 interleaved repetitions.

Workload Bars ManifoldBT vectorbt raptorbt
SMA crossover 10M 317 ms 24.75 s (x78) 878 ms (x2.8)
...with drawdown, Sharpe, Sortino, volatility 10M 317 ms 97.46 s (x308) 894 ms (x2.8)
...with a 5 bps fee and 2 bps slippage 10M 316 ms 24.53 s (x78) not supported
EMA + RSI filter, 5 bps fee 1M 52 ms 2.21 s (x41) not supported
Five assets in one book 1M 140 ms 2.34 s (x17) not supported

The second row is the one worth reading twice. Asking for a performance summary costs ManifoldBT nothing measurable, because it computes one during the run whether you read it or not, and costs vectorbt 73 seconds, because it defers the equity curve until a risk metric needs it and then has to build one.

The fifth row is the one where ManifoldBT does worst, and it is published for that reason: broadcasting a column per asset is close to free for vectorbt, while walking five books is not free for anything.

Parameter sweeps

Bars Combinations ManifoldBT vectorbt raptorbt
20,000 5,000 446 ms, 40 MB 5.84 s, 2.5 GB 7.08 s
200,000 10,000 9.96 s, 79 MB out of memory 164.50 s

Past a certain grid the question stops being speed. vectorbt materialises the simulation per combination, 1.57 MB of it at 20,000 bars, so the second row would ask a machine for tens of gigabytes. ManifoldBT runs it in ten seconds inside 79 MB.

Reproduce any of it yourself: fork the repository and press Run workflow on the benchmark, or run it locally from benchmarks/vs_vectorbt/. The method, the parity gate and the known divergences are written up in its README.

Against an event-driven engine

backtrader runs the same EMA(12/26) + RSI(14) strategy on 500K 1-minute bars in 46,944 ms, against 13 ms for ManifoldBT: a factor of 3,556. Measured with benchmarks/bench_vs_competitors.py, median of 3 runs. It sits outside the CI suite because its event-driven fills produce a different PnL, and the parity gate publishes no timing for engines that did not do the same work.

How it compares

ManifoldBT vectorbt backtrader Nautilus
Engine Rust (vectorized + sequential fills) Numba/NumPy (vectorized) Python (event-driven) Rust/Python (event-driven)
Execution realism¹ High Basic High High
Focus Backtesting + research Backtesting at scale Backtest + live Backtest + live (production)

¹ fees, slippage, funding, partial fills, look-ahead detection.

On GPU (Pro), the Monte Carlo engine runs ~36x faster than the all-core CPU path (SDE path simulation, RTX 3090, f32).

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
Free connectors (Binance, Bybit, Hyperliquid, dYdX, Bitstamp, Yahoo) Yes Yes
Databento & Massive connectors - Yes
Safety checks (lookahead, exposure) - Yes
Tearsheets & export - Yes

License

Apache 2.0 with Commons Clause. The source is available, free to use, modify and self-host. Reselling the software or offering it as a paid hosted service is not permitted. See LICENSE for the full text.

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

manifoldbt-0.19.0-cp39-abi3-win_amd64.whl (9.0 MB view details)

Uploaded CPython 3.9+Windows x86-64

manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ x86-64

manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_aarch64.whl (8.2 MB view details)

Uploaded CPython 3.9+musllinux: musl 1.2+ ARM64

manifoldbt-0.19.0-cp39-abi3-manylinux_2_34_x86_64.whl (8.8 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.34+ x86-64

manifoldbt-0.19.0-cp39-abi3-manylinux_2_28_aarch64.whl (8.1 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

manifoldbt-0.19.0-cp39-abi3-macosx_11_0_arm64.whl (7.6 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

manifoldbt-0.19.0-cp39-abi3-macosx_10_12_x86_64.whl (8.3 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: manifoldbt-0.19.0-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 9.0 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2089b52261ac95502f84bbedee2598c5e32e855e2fa98118166647f17e8c3e8b
MD5 3ff80e0b53f202f99be9675e608ce695
BLAKE2b-256 f98fc9695c1add724fba65ab5000ae51b4b80b0d27fe3bc6f5f0a4a74e03c38c

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4ebb3d7b78dfbb50c3414db482414f959a365a69251b8a63b4c5b5d6d8cbc305
MD5 0b33ec985e9808a9f7fa73140bc7b22f
BLAKE2b-256 abde9d679768e14d3e9783f7c51c649a3e15c64c695817528e1e6f62adc3547f

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 4e055179f71bf5abba997449e0c1056e9fb269573a8b1c5620a4d27b3af88e68
MD5 03004da60efdc5381406fe49fb7d2542
BLAKE2b-256 4bb2c73acdb2760546ac226f49e25f84b28cf7b3357017e033e73ef160436083

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 851f4edb143ca7eec8807ac437afdcef24c8936be7f7a127239de4877a467ecb
MD5 e1aaaf24dee54f29633c2155f800e965
BLAKE2b-256 5d5ea02cbc2598e46ab77de976ad915fa5d7ca3e384bdfb55f7e3cf97145f95d

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9979f0e4209527ef57b928a3bbb32175eb7ba6581a7d9d00c7229a8dc80cf0fb
MD5 810837a6379a520666fc984f9763b31b
BLAKE2b-256 b97bd94227e3168980f75ace0e6cfef8603994f8d7325349aa7022affda00247

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 76d28f7bbb2c28c7c6f48e7b9d4cbb22fc0d1d0b7a139f3bc5ecbc7d060eeeae
MD5 33d5c271cdf9f087f78bb99a8f4c1f9a
BLAKE2b-256 a004b30d406febcc478c527e08e7c179fcdfbed96e16c00b9ac042735295ec0d

See more details on using hashes here.

File details

Details for the file manifoldbt-0.19.0-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for manifoldbt-0.19.0-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 1b53e183a4025bedddb475db6e070a31adbb93d5ee563a1acc42a95310d7baad
MD5 7ccd40c1df87086e9d2b9a28422fb9e5
BLAKE2b-256 39f2dbb47a4677db78c9fe2c9a264424b63bc03dc861ab8db327cb293a52cf9c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.24.0

7 files

0.23.0

7 files

0.22.0

7 files

0.21.0

7 files

0.20.1

7 files

0.20.0

7 files

0.19.1

7 files

This release

0.19.0 This release

7 files

0.18.0

7 files

0.17.3

7 files

0.17.2

7 files

0.17.1

7 files

0.17.0

7 files

0.16.0

7 files

0.15.0

7 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page