Welcome to HftBacktest
HftBacktest is a high-frequency trading and market-making backtesting framework designed for developing HFT strategies with accurate simulation of market conditions.Installation
Get started with Python or Rust installation
Quick Start
Run your first backtest in minutes
Examples
Learn market-making strategies and techniques
API Reference
Explore the complete API documentation
Key Features
Accurate Fill Simulation
Simulates order fills accounting for queue position and latencies
Full Order Book Replay
Complete tick-by-tick simulation with Level-2 and Level-3 support
Latency Modeling
Accounts for both feed and order latency using custom models
Multi-Asset Support
Backtest strategies across multiple assets and exchanges
High Performance
Python code runs in Numba JIT, Rust provides native performance
Live Trading
Deploy the same code for live trading (Rust only)
Why Accurate Backtesting Matters
Trading is a highly competitive field where only small edges usually exist, but they can still make a significant difference. Because of this, backtesting must accurately simulate real-world conditions.Foundation First: Accurate backtesting is the foundation. Without it, all further analysis—whether conservative or aggressive—becomes unreliable.
- Not overly pessimistic: Avoids hiding small edges and profit opportunities
- Not overly optimistic: Prevents unrealistic simulation that overstates performance
- Validation ready: Backtests should closely align with live trading results for the same period
What You Can Build
Market Making
Build sophisticated market-making strategies with spread management
Grid Trading
Implement high-frequency grid trading with queue positioning
Arbitrage
Develop cross-exchange arbitrage strategies
Statistical Arbitrage
Create multi-asset statistical arbitrage strategies
Alpha Strategies
Integrate alpha signals with market-making
Risk Management
Test risk mitigation in extreme market conditions
Language Support
HftBacktest is available in two implementations:Python
- Version: Python 3.11+
- Performance: Runs in Numba JIT for near-native speed
- Use Case: Rapid prototyping, research, and strategy development
- Ecosystem: Integrates with NumPy, Polars, Matplotlib
Rust
- Version: Rust 1.91.1+
- Performance: Native compiled performance
- Use Case: Production backtesting and live trading deployment
- Features: Type safety, memory safety, concurrent execution
Getting Started
Ready to start backtesting? Follow these steps:Next: Install HftBacktest
Get HftBacktest installed on your system