finds.dev← search

// the find

nkaz001/hftbacktest

★ 4,178 · Rust · MIT · updated Dec 2025

Free, open source, a high frequency trading and market making backtesting and trading bot, which accounts for limit orders, queue positions, and latencies, utilizing full tick data for trades and order books(Level-2 and Level-3), with real-world crypto trading examples for Binance and Bybit

hftbacktest is a backtesting framework specifically for high-frequency trading and market making strategies, with explicit modeling of order queue position, feed latency, and order latency. It's written in Rust with Python bindings via PyO3/Numba, targeting quant developers who need simulation fidelity beyond what event-driven backtesting tools like Backtrader provide. The use case is narrow and intentional: if you're not doing sub-second crypto market making, most of this is irrelevant to you.

Queue position modeling is the standout feature — most backtesting tools assume your limit order fills at the top of queue, which is wildly optimistic for HFT. This models where your order sits and whether it actually fills. The dual-layer latency model (feed latency separate from order latency) lets you replay what the exchange saw vs. what you saw, which is the actual source of most live-vs-backtest divergence. The Rust core with Numba-compatible Python bindings means you're not paying a speed penalty to iterate in Python — the hot loop runs at native speed. Level-3 order-by-order book reconstruction is genuinely rare in open-source tools.

Crypto-only, and specifically Binance and Bybit — there's no path to equities, options, or non-crypto futures without writing your own connector from scratch. Data pipeline setup is a real barrier: you need to source, download, and normalize full tick data yourself before you can run a single backtest, and the data format is custom numpy structured arrays. The Python API requires Numba JIT — your strategy function must be decorated with @njit, which rules out most Python libraries and debugging tools inside the hot loop. Live trading is Rust-only with no Python equivalent, so your research-in-Python to production-in-Rust translation gap is your problem to solve.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →