From c4e7e9abb4f2eaf8c1f4dc599248649365e231a3 Mon Sep 17 00:00:00 2001 From: Jimmy7892 Date: Tue, 17 Mar 2026 16:23:22 +0100 Subject: [PATCH] fix: benchmark timestamp ns, vectorbt trade count x2, remove fake perf numbers from README --- README.md | 12 ++++-------- benchmarks/bench_vs_competitors.py | 4 ++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3cfae9b..490d05b 100644 --- a/README.md +++ b/README.md @@ -90,15 +90,11 @@ See the [examples/](examples/) directory for complete runnable strategies: ## Performance -ManifoldBT's Rust engine is orders of magnitude faster than pure-Python alternatives: +Run the benchmark yourself: -| Engine | 500K bars | 5M bars | -|--------|-----------|---------| -| **ManifoldBT** | ~0.02s | ~0.15s | -| vectorbt | ~0.8s | ~8s | -| backtrader | ~12s | ~120s+ | - -Run `python benchmarks/bench_vs_competitors.py` to reproduce. +```bash +python benchmarks/bench_vs_competitors.py --rows 500000 --runs 5 +``` ## License diff --git a/benchmarks/bench_vs_competitors.py b/benchmarks/bench_vs_competitors.py index e276931..b81a4d4 100644 --- a/benchmarks/bench_vs_competitors.py +++ b/benchmarks/bench_vs_competitors.py @@ -62,7 +62,7 @@ def bench_bt_engine(df: pd.DataFrame, n_runs: int) -> dict: # Write synthetic data to a temp parquet (manifoldbt canonical schema) parquet_df = pd.DataFrame({ - "timestamp": pd.to_datetime(df["timestamp"].values, utc=True), + "timestamp": pd.to_datetime(df["timestamp"].values, utc=True).as_unit("ns"), "symbol_id": np.uint32(1), "open": df["open"].values, "high": df["high"].values, @@ -217,7 +217,7 @@ def bench_vectorbt(df: pd.DataFrame, n_runs: int) -> dict: "median": np.median(times), "mean": np.mean(times), "total_return": stats.get("Total Return [%]", None), - "trades": stats.get("Total Trades", None), + "trades": int(stats.get("Total Trades", 0)) * 2, # vbt counts round-trips; x2 for entry+exit }