Scripts2026年7月26日·1 分钟阅读

vectorbt — High-Performance Quantitative Backtesting in Python

A Python library for fast backtesting, analysis, and visualization of trading strategies using vectorized operations on NumPy and pandas.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
vectorbt Overview
直接安装命令
npx -y tokrepo@latest install d92390ad-890f-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

Introduction

vectorbt is a Python library designed for quantitative traders and researchers who need to test thousands of strategy variations quickly. By leveraging NumPy broadcasting and vectorized operations instead of row-by-row iteration, it achieves orders-of-magnitude speedups over traditional event-driven backtesting frameworks, making exhaustive parameter sweeps practical.

What vectorbt Does

  • Runs vectorized backtests on trading strategies with minimal code
  • Computes portfolio performance metrics (Sharpe, Sortino, max drawdown, etc.) across parameter grids
  • Provides technical indicator wrappers (MA, RSI, BBANDS, etc.) with broadcasting support
  • Generates interactive Plotly-based visualizations of equity curves, drawdowns, and trade analysis
  • Supports multi-asset portfolio simulation with position sizing and fees

Architecture Overview

vectorbt represents data as multi-dimensional NumPy arrays where extra dimensions encode parameter combinations. Indicators, signals, and portfolio logic operate on these arrays using broadcasting, so a single backtest call can evaluate thousands of parameter sets simultaneously. The Portfolio class simulates order execution, tracks positions, and computes statistics. Numba JIT compilation accelerates custom logic where pure NumPy is insufficient.

Self-Hosting & Configuration

  • Install via pip install vectorbt with optional extras for data downloads
  • Use vbt.settings to configure global defaults for plotting, data caching, and computation
  • Set freq parameter on time series to ensure correct annualization of metrics
  • Enable Numba acceleration with @njit decorators for custom signal logic
  • Configure data sources via vbt.YFData, vbt.BinanceData, or custom data feeds

Key Features

  • Vectorized execution enables testing millions of parameter combinations in seconds
  • Built-in technical indicators that natively support parameter arrays
  • Interactive Plotly visualizations for equity curves, trade scatter plots, and heatmaps
  • Flexible portfolio simulation with configurable fees, slippage, and position sizing
  • Numba-accelerated custom indicators and signals

Comparison with Similar Tools

  • Backtrader — Event-driven, easier to understand but much slower for parameter sweeps
  • Zipline — Quantopian legacy framework; vectorbt is more flexible and actively maintained
  • bt — Tree-based strategy composition; vectorbt excels at brute-force parameter optimization
  • QuantStats — Analytics and reporting only; vectorbt includes the full backtest loop
  • pandas-ta — Indicator library only; vectorbt adds backtesting and portfolio simulation

FAQ

Q: How fast is vectorbt compared to event-driven frameworks? A: Depending on the strategy, vectorbt can be 100x to 1000x faster than row-by-row backtesters because it processes entire arrays at once.

Q: Can I use vectorbt for live trading? A: vectorbt is primarily a research and backtesting tool. For live trading, use its signal generation with a separate execution layer.

Q: Does vectorbt support cryptocurrency data? A: Yes. It includes built-in data downloaders for Yahoo Finance and Binance, and accepts any pandas DataFrame.

Q: What license does vectorbt use? A: vectorbt is released under a custom source-available license. Check the repository for details.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产