Quick answer
HftBacktest is an open-source framework for backtesting high-frequency and market-making strategies on full order-book and trade data. It models your order’s queue position and both feed and order latencies, so limit-order fills are realistic. The core is Rust with Python bindings (Numba-compatible), and it includes live connectors for Binance Futures and Bybit.
HftBacktest at a glance
- Category
- HFT & market making
- Language
- Rust, Python
- License
- MIT
- Does
- Backtesting, Live trading, Market making
- Markets
- Crypto, Futures
- Best for
- Market making and other limit-order strategies where queue position and latency decide profitability.
- In AlgoGP
- Use the exported strategy object from your own code
Pick it if
Market making and other limit-order strategies where queue position and latency decide profitability.
Watch out for
Requires large tick datasets.
HftBacktest strengths and limitations
Strengths
- Queue-position and latency modelling.
- Level-2/3 and tick data replay.
- Rust speed with a Python API.
Limitations
- Requires large tick datasets.
- Specialist tool with a steep learning curve.
HftBacktest example
pip install hftbacktestfrom hftbacktest import BacktestAsset, HashMapMarketDepthBacktest
asset = (BacktestAsset().data(["btcusdt_20240101.npz"]).linear_asset(1.0)
.constant_latency(10_000_000, 10_000_000).risk_adverse_queue_model()
.tick_size(0.1).lot_size(0.001))
hbt = HashMapMarketDepthBacktest([asset])Use HftBacktest with AlgoGP
AlgoGP does not add HftBacktest to projects automatically yet, but nothing stops you using them together. Every AlgoGP project exports plain Python with a framework-neutral strategy object, so you can call it from HftBacktest yourself.
- 1
Design and backtest in AlgoGP
Describe the idea to the copilot and backtest it on AlgoGP’s normalized history.
- 2
Add any bridge to get the adapter core
Adding a bridged framework (for example Backtrader) writes
frameworks/algogp_bridge.py, whoseStrategyBridge.on_bar()returns the orders the strategy wants. - 3
Call it from HftBacktest
Feed HftBacktest’s bars to
StrategyBridge, place the returned orders with HftBacktest, and report fills back withsync().
HftBacktest connects to Binance, Bybit, Databento. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.
HftBacktest: frequently asked questions
Where do I get data for HftBacktest?
Record exchange WebSocket feeds or buy tick data (e.g. Tardis, Databento) and convert it to its format.
HftBacktest alternatives
- NautilusTraderPython, RustHigh-performance, Rust-core trading platform with a Python API: the same strategy runs in a nanosecond-resolution backtester and live across many venues.
- HummingbotPython, CythonOpen-source framework for crypto market making and arbitrage: connectors for CEXs and DEXs, Strategy V2 controllers, scripts and a REST API.
- BarterRustRust libraries for event-driven live trading, paper trading and backtesting, with normalized exchange streams (barter-data) and execution.
- PassivbotPython, RustGrid and trailing-entry trading bot for perpetual futures, written in Python and Rust, with a backtester and evolutionary optimizer.
Independent guide. AlgoGP is not affiliated with HftBacktest. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.