Quick answer
vectorbt is a Python library that backtests by operating on whole arrays at once with pandas and Numba instead of looping bar by bar. You build entry and exit signal arrays (or orders) and call Portfolio.from_signals, which simulates fees, slippage and sizing across thousands of parameter combinations in seconds. A commercial successor, vectorbt PRO, adds more features.
vectorbt at a glance
- Category
- Research & vectorized backtesting
- Language
- Python
- License
- Apache-2.0 with Commons Clause
- Does
- Backtesting, Optimization, Performance analytics, Indicators
- Markets
- Stocks, ETFs, Crypto, Forex, Futures
- Best for
- Parameter sweeps and research over many symbols or settings, before committing to an event-driven engine.
- In AlgoGP
- Built-in bridge: add it to any project
Pick it if
Parameter sweeps and research over many symbols or settings, before committing to an event-driven engine.
Watch out for
Path-dependent logic (trailing stops, complex state) is awkward to vectorize.
vectorbt strengths and limitations
Strengths
- Orders of magnitude faster than loop-based backtesters for sweeps.
- Broadcasting: test a grid of parameters across many assets in one call.
- Interactive Plotly charts and rich statistics.
Limitations
- Path-dependent logic (trailing stops, complex state) is awkward to vectorize.
- Open-source version is in maintenance; new features go to vectorbt PRO.
- Commons Clause license restricts selling it as a service.
vectorbt example
pip install vectorbtimport vectorbt as vbt
close = vbt.YFData.download("BTC-USD").get("Close")
fast = vbt.MA.run(close, [10, 20, 50], short_name="fast")
slow = vbt.MA.run(close, [100, 200], short_name="slow")
entries, exits = fast.ma_crossed_above(slow), fast.ma_crossed_below(slow)
pf = vbt.Portfolio.from_signals(close, entries, exits, fees=0.001)
print(pf.total_return().sort_values().tail())Use vectorbt with AlgoGP
AlgoGP has a built-in vectorbt bridge. Describe the strategy to the copilot and backtest it in AlgoGP, then open the project’s APIs & keys tab and add vectorbt under Frameworks. The project gains these files, saved as a new version and included in every export:
frameworks/algogp_bridge.pyframeworks/tests/test_bridge.pyframeworks/vectorbt_signals.pyrequirements.txtgains:vectorbt
python frameworks/vectorbt_signals.pyvectorbt connects to Yahoo Finance, Binance, Alpaca. Each guide shows how to create the API key, which you can store in the project’s Keys & secrets.
vectorbt: frequently asked questions
Is vectorbt free?
The open-source version is free under Apache-2.0 with Commons Clause; vectorbt PRO is a paid subscription.
vectorbt vs Backtrader?
vectorbt is far faster for sweeps; Backtrader is easier for path-dependent, event-driven logic and live trading.
vectorbt alternatives
- backtesting.pyPythonSmall, fast Python backtesting library: subclass Strategy, call Backtest.run(), get stats, an interactive Bokeh chart and built-in optimization.
- BacktraderPythonThe classic Python event-driven backtesting library: Cerebro, data feeds, analyzers, sizers and plotting, with live stores for IB and OANDA.
- PyBrokerPythonPython framework for machine-learning trading strategies: walk-forward analysis, bootstrapped metrics and a fast Numba backtesting engine.
- btPythonFlexible Python framework for portfolio-level backtests built from composable algos: select, weigh and rebalance on a schedule.
Independent guide. AlgoGP is not affiliated with vectorbt. Features, licenses and maintenance change; check the official documentation. Nothing here is investment advice.