Skip to main content

Installation

HftBacktest is available for both Python and Rust. Choose the installation method that matches your preferred development environment.

Python Installation

Requirements

HftBacktest requires Python 3.11 or higher
The Python package has the following dependencies:
  • numpy >= 2.0, < 2.3
  • numba ~= 0.61
  • polars
  • matplotlib
  • holoviews

Install via pip

1

Install the package

The simplest way to install HftBacktest is using pip:
pip install hftbacktest
This will install the latest stable release from PyPI.
2

Verify installation

Test your installation by importing the package:
import hftbacktest
print(hftbacktest.__version__)

Install from Source

For the latest development version, you can install directly from the GitHub repository:
1

Clone the repository

git clone https://github.com/nkaz001/hftbacktest
cd hftbacktest/py-hftbacktest
2

Install with pip

pip install -e .
The -e flag installs the package in editable mode, useful for development.

Optional Dependencies

For additional data source support, install the optional dependencies:
# Databento data support
pip install hftbacktest[databento]

Rust Installation

Requirements

HftBacktest requires Rust 1.91.1 or higher

Add to Cargo.toml

Add HftBacktest as a dependency in your Cargo.toml:
[dependencies]
hftbacktest = "0.9.4"

Feature Flags

The Rust crate provides several optional features:
FeatureDescriptionDefault
backtestBacktesting engine and data processing
liveLive trading bot support (Binance, Bybit)
s3AWS S3 data loading support

Build Your Project

After adding the dependency, build your project:
cargo build --release
Always use --release mode for backtesting to get optimal performance. Debug builds can be 10-100x slower.

Verify Installation

Create a simple test to verify the installation:
use hftbacktest::prelude::*;

fn main() {
    println!("HftBacktest installed successfully!");
}
Run it with:
cargo run --release

Development Setup

For contributing or development purposes:
1

Clone the repository

git clone https://github.com/nkaz001/hftbacktest
cd hftbacktest
2

Python development

Install Python package in development mode:
cd py-hftbacktest
pip install -e .
3

Rust development

Build the Rust crate:
cd hftbacktest
cargo build --release

Platform-Specific Notes

Linux

All features work out of the box on Linux. For optimal performance:
# Install build essentials if not present
sudo apt-get update
sudo apt-get install build-essential

macOS

Python and Rust installations work normally on macOS:
# Install Rust if needed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Windows

Both Python and Rust are supported on Windows:
For Rust on Windows, you may need to install the Microsoft C++ Build Tools.

ARM Architecture

For ARM platforms (including Apple Silicon):
# Additional dependency is handled automatically
# aws-lc-rs is used with bindgen feature

Next Steps

Now that you have HftBacktest installed, you’re ready to run your first backtest:

Quick Start

Run your first backtest with a simple example

Data Preparation

Learn how to prepare market data for backtesting

Troubleshooting

HftBacktest requires NumPy 2.0+. If you have conflicts:
pip install --upgrade numpy
pip install --force-reinstall hftbacktest
Ensure you have the correct Numba version:
pip install numba~=0.61
The first build can take several minutes. Subsequent builds are faster. Use cargo build --release -j 4 to limit parallel jobs if you have memory constraints.
On Linux, install OpenSSL development libraries:
sudo apt-get install libssl-dev pkg-config

Getting Help

If you encounter issues:

Build docs developers (and LLMs) love