HftBacktest is a Rust framework designed for developing and running high-frequency trading and market-making strategies. It focuses on accounting for both feed and order latencies, as well as the order queue position for order fill simulation.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nkaz001/hftbacktest/llms.txt
Use this file to discover all available pages before exploring further.
Key Features
- Complete tick-by-tick simulation with a variable time interval
- Full order book reconstruction based on Level-2 feeds (Market-By-Price) and Level-3 feeds (Market-By-Order)
- Backtest accounting for both feed and order latency, using provided models or custom models
- Order fill simulation that takes into account the order queue position
- Backtesting of multi-asset and multi-exchange models
- Deployment of a live trading bot using the same algo code
Feature Flags
Thedefault feature enables both backtest and live features.
backtest: Enables backtesting featureslive: Enables live trading bot functionalitys3: Enables accessing data files from S3
Module Structure
The HftBacktest API is organized into several key modules:Core Modules
- types - Core type definitions including
Order,Event,Side,Status,TimeInForce, andOrdType - backtest - Backtesting functionality including
Backtest,Asset, and builders - depth - Market depth implementations for order book management
- live - Live trading bot functionality
Common Patterns
The framework uses a builder pattern for constructing backtesting and live trading instances:Bot Trait
Both backtesting and live trading implement theBot trait, providing a unified interface:
Getting Started
- Add HftBacktest to your
Cargo.toml:
- Import the prelude for common types:
- Build your backtest or live bot using the builder pattern
- Implement your trading strategy using the
Bottrait methods
Next Steps
- Core Types - Learn about fundamental types like
Order,Event, and enums - Backtest Module - Set up backtesting with custom models
- Market Depth - Understand order book implementations
- Live Trading - Deploy strategies in production