Installation & Setup
Relevant source files
The following files were used as context for generating this wiki page:
VectorBT is a high-performance Python library designed for backtesting and analyzing trading strategies at scale. It leverages a matrix-based approach, utilizing NumPy, Pandas, and Numba for computational efficiency. The installation ecosystem is modular, offering a core package with several optional extensions for specialized tasks such as Rust acceleration, technical analysis integrations, and automated documentation generation.
The project supports Python versions 3.11 through 3.14. Its architecture allows for transparent switching between different execution engines, primarily Numba (JIT) and an optional Rust engine for precompiled performance.
Sources: pyproject.toml:17-17, README.md:55-58, rust/README.md:15-18
Core Installation
The primary method for installing the stable version of VectorBT is through the Python Package Index (PyPI). The core installation includes essential dependencies for data manipulation and visualization, such as numpy, pandas, scipy, matplotlib, plotly, and numba.
pip install -U vectorbt
Sources: README.md:83-85, pyproject.toml:34-51
Python Version Compatibility
VectorBT requires a specific range of Python versions to ensure compatibility with its high-performance dependencies like Numba.
| Requirement | Value |
|---|---|
| Supported Python | >= 3.11, < 3.15 |
| Primary Dependencies | numpy >= 2.4.6, pandas >= 3.0.3 |
Sources: pyproject.toml:17-36
Optional Dependencies & Extensions
VectorBT provides several optional dependency groups to extend its functionality. These are managed via project.optional-dependencies in the configuration.
Extension Groups Table
| Group | Command | Description |
|---|---|---|
| Rust | pip install "vectorbt[rust]" | Installs the Rust-accelerated kernel engine. |
| Full | pip install "vectorbt[full]" | Adds TA-Lib, yfinance, CCXT, Ray, and other trading tools. |
| Test | pip install "vectorbt[test]" | Tools for development: pytest, coverage, and xdist. |
| Docs | pip install "vectorbt[docs]" | MkDocs and plugins for generating documentation. |
| All | pip install "vectorbt[all]" | Installs every available extension group. |
Sources: pyproject.toml:53-83, README.md:87-99
Rust Engine Setup
The Rust engine provides high-performance drop-in replacements for Numba kernels. It is distributed as the vectorbt-rust package.
The diagram above illustrates how the vectorbt/_engine.py resolver transparently dispatches calls based on availability and configuration.
Sources: rust/README.md:15-20, rust/README.md:46-56
Building From Source
For developers contributing to the project or requiring the latest features, VectorBT can be installed in editable mode. Building the Rust extension from source requires maturin.
Rust Engine Compilation
The Rust component uses maturin as a build backend and requires the Rust toolchain to be present on the system.
# From repository root
python -m pip install -U pip maturin
python -m pip install -e ".[test]"
python -m maturin develop --manifest-path rust/Cargo.toml --release
Sources: rust/README.md:31-36, rust/pyproject.toml:1-6
Specialized Setup for Applications
The repository contains standalone applications, such as the Candlestick Patterns tool, which may have their own setup requirements. These applications are often structured to work with uv or Docker for environment isolation.
Using uv for Apps
The uv package manager is recommended for fast environment creation and dependency resolution within application directories.
cd vectorbt/apps/candlestick-patterns
uv venv
uv pip install -r requirements.txt
uv run python app.py
Sources: apps/candlestick-patterns/README.md:20-30
Docker Deployment
Applications can also be deployed via Docker, which handles the complex environment setup including Numba JIT requirements.
docker build -t candlestick-patterns .
docker run -p 8050:8050 -e HOST='0.0.0.0' candlestick-patterns
Sources: apps/candlestick-patterns/README.md:43-47
Verification and Benchmarking
Once installed, the setup can be verified by running the test suite or benchmark scripts to ensure the engines are performing correctly.
Testing Engines
Tests specifically targeting engine parity and Rust availability are located in the tests/ directory.
# Run engine-focused tests
pytest tests/test_engine.py
# Run full suite
pytest
Sources: rust/README.md:73-82
Benchmark Tooling
The benchmarks/ directory provides scripts to compare Numba and Rust execution times. A single run can be performed with parity checks.
python benchmarks/bench_engine.py --rows 5000 --cols 50 --check
Sources: benchmarks/README.md:27-29
The installation and setup of VectorBT is designed to be flexible, supporting everything from a standard pip install for researchers to complex source builds for high-frequency trading architects requiring maximum performance through Rust acceleration.
Sources: README.md:55-60, rust/README.md:104-106