How nkaz001/hftbacktest works
HftBacktest is a market-replay backtesting framework for HFT and market-making strategies, with a Rust live-trading path and Python/Numba interface. The principal workflow is to prepare market data, configure assets and simulation models, run a strategy against reconstructed books, and inspect results; live deployment reuses strategy logic through exchange connectors. The graph preserves the collector and exchange integration branches as well as the documented backtest capabilities. Some subsystem paths are directories because their implementation files were not sampled; unsampled call relationships are omitted.
Main entry points: mod.rs Backtest Runtime · main.rs Connector Runtime · src Exchange Feeds · __init__.py Python API
Components 21
Market Data
- Data Collector
collector/src/main.rs - Exchange Feeds
collector/src - Request Throttling
collector/src/throttler.rs - Data Writer
collector/src/file.rs - Data Utilities
py-hftbacktest/hftbacktest/data/utils - Data Validation
py-hftbacktest/hftbacktest/data/validation.py
Backtest Engine
- Replay Data Reader
hftbacktest/src/backtest/data/reader.rs - Backtest Runtime
hftbacktest/src/backtest/mod.rs - Market Depth
hftbacktest/src/depth - Queue Fill Models
hftbacktest/src/backtest/models/queue.rs - Exchange Fill Process
hftbacktest/src/backtest/proc/partialfillexchange.rs
Python Interface
- Python API
py-hftbacktest/hftbacktest/__init__.py - Native Backtest Binding
py-hftbacktest/src/lib.rs - Performance Statistics
py-hftbacktest/hftbacktest/stats/stats.py
Live Trading
- Live Bot Runtime
hftbacktest/src/live/bot.rs - Live IPC
hftbacktest/src/live/ipc
Exchange Connectors
- Connector Runtime
connector/src/main.rs - Binance Futures
connector/src/binancefutures - Binance Spot
connector/src/binancespot - Bybit
connector/src/bybit
Other components
- Strategy Developer
Connections 21
- Strategy Developer → Data Collector: collects feeds
collector/src/main.rs - Data Collector → Exchange Feeds: dispatches exchange
collector/src/main.rs - Exchange Feeds → Request Throttling: throttles snapshots
collector/src/binance/mod.rs - Exchange Feeds → Data Writer: sends records
collector/src/binance/mod.rs - Strategy Developer → Data Utilities: prepares data
- Data Utilities → Data Validation: validates data
py-hftbacktest/hftbacktest/data/utils/tardis.py - Data Validation → Replay Data Reader: supplies replay data
- Strategy Developer → Python API: configures strategy
- Python API → Native Backtest Binding: calls native runtime
- Native Backtest Binding → Backtest Runtime: builds backtest
py-hftbacktest/src/lib.rs - Backtest Runtime → Replay Data Reader: reads replay data
hftbacktest/src/backtest/mod.rs - Backtest Runtime → Market Depth: updates market depth
hftbacktest/src/lib.rs - Backtest Runtime → Queue Fill Models: uses queue model
hftbacktest/src/backtest/mod.rs - Backtest Runtime → Exchange Fill Process: simulates fills
hftbacktest/src/backtest/mod.rs - Python API → Performance Statistics: analyzes results
- Strategy Developer → Live Bot Runtime: deploys strategy
- Live Bot Runtime → Live IPC: communicates through
- Live Bot Runtime → Connector Runtime: routes live orders
- Connector Runtime → Binance Futures: selects exchange
connector/src/main.rs - Connector Runtime → Binance Spot: selects exchange
connector/src/main.rs - Connector Runtime → Bybit: selects exchange
connector/src/main.rs