# Vectorbt

High-performance vectorized backtesting with parameter optimization, portfolio...

- Repository: https://github.com/agiprolabs/claude-trading-skills (507 stars)
- Category: Engineering
- License: MIT
- Last updated: 2026-09-03
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add agiprolabs/claude-trading-skills --skill vectorbt -g -a claude-code -y`
Codex: `npx skills add agiprolabs/claude-trading-skills --skill vectorbt -g -a codex -y`
Cursor: `npx skills add agiprolabs/claude-trading-skills --skill vectorbt -g -a cursor -y`
Gemini CLI: `npx skills add agiprolabs/claude-trading-skills --skill vectorbt -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add agiprolabs/claude-trading-skills`

## Description

High-performance vectorized backtesting with parameter optimization, portfolio simulation, and rich performance metrics

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Vectorized Backtesting with vectorbt

## Overview

vectorbt is a Python library for **vectorized backtesting**, running strategy simulations using NumPy/pandas array operations instead of bar-by-bar loops. This makes it 100, 1000x faster than event-driven frameworks (backtrader, zipline), enabling parameter optimization across thousands of combinations in seconds.

**Key strengths:**
- Blazing speed via NumPy vectorization
- Built-in parameter grid search and optimization
- 50+ built-in performance metrics (Sharpe, Sortino, Calmar, max drawdown, profit factor)
- Rich plotting (equity curves, drawdowns, trade markers, heatmaps)
- Native pandas integration, your data stays in DataFrames throughout

## Installation

```bash
uv pip install vectorbt pandas numpy
```

vectorbt pulls in pandas, NumPy, and Plotly automatically. For technical indicators, also install pandas-ta:

```bash
uv pip install vectorbt pandas-ta
```

## Core Concepts

### 1. Signals, Boolean Entry/Exit Arrays

Strategies in vectorbt are expressed as boolean pandas Series (or arrays) indicating where to enter and exit positions:

```python
import vectorbt as vbt
import pandas as pd

# Entry: buy when fast EMA crosses above slow EMA
entries = fast_ema > slow_ema
# Exit: sell when fast EMA crosses below slow EMA
exits = fast_ema < slow_ema
```

vectorbt resolves conflicting signals automatically (you can't enter while already in a position).

### 2. Portfolio, The Backtesting Engine

`vbt.Portfolio.from_signals()` is the primary backtesting function. It takes price data and entry/exit signals, simulates trades, and computes performance:

```python
pf = vbt.Portfolio.from_signals(
    close=close_prices,
    entries=entries,
    exits=exits,
    init_cash=10_000,
    fees=0.003,       # 0.3% per trade
    slippage=0.005,   # 0.5% slippage
    freq="1h",        # hourly data
)
```

### 3. Metrics, Built-in Performance Analysis

```python
# Full stats summary
print(pf.stats())

The rest: https://github.com/agiprolabs/claude-trading-skills/blob/HEAD/skills/vectorbt/SKILL.md
