Getting started¶
VectorBT PRO (vectorbtpro) is a next-generation engine for backtesting, algorithmic trading, and research. It's a high-performance, actively-developed, proprietary successor to the vectorbt library, one of the world's most innovative open-source backtesting packages. The PRO version extends the open-source package with new impressive features and useful enhancements.
This tool is a community-led initiative to fix information asymmetry in trading. We bring many SOTA tools and libraries under one umbrella and automate them. Our vision is to make quantitative analysis and algorithmic trading accessible to everyone. Join us!
VectorBT PRO has been completely refactored to improve performance and enable new groundbreaking features, such as parallelization support.
VectorBT PRO enjoys priority in development and maintenance. All major enhancements will be exclusively and immediately available to all eligible sponsors.
VectorBT PRO provides a range of features and examples to make it more intuitive and easier to use. Our goal is to automate as many backtesting components as possible.
Join a Discord server with 500+ members to share ideas and help each other out. Get assistance faster and in more detail.
Get access to a range of exclusive articles and tutorials covering many aspects and best practices of using the library.
Regardless of whether you're a newbie or a seasoned programming prophet, you'll learn how to use the hottest Python tools to your own advantage in trading.
VectorBT PRO is powered by its community. Financial contributions like yours ensure that the software is safe to use for the years to come. Thank you!
What is VectorBT PRO?¶
VectorBT PRO is a Python package that combines a variety of acceleration and data science tools to make trading strategies and markets more transparent to quants.
One of the unique features of VBT is the ability to represent any trading setup as a set of multidimensional arrays, where each column represents a separate configuration of a trading strategy and its environment. This approach allows building and backtesting entire grids of parameters at the speed of C, while the results can be analyzed in detail using the Python's vibrant package ecosystem - the best of both worlds. Learn more.
Why VectorBT PRO?¶
VectorBT PRO follows an approach totally opposite to that of a conventional backtesting software: instead of running a backtesting job as a single monolithic process, VBT divides the job into dozens of isolated components that can be composed by the user like Lego bricks and run independently of each other; such components include data, indicators, signals, allocations, portfolio, and more. Each component has its own ecosystem of analysis tools, enabling quants to analyze many facets of a trading strategy even before it hits the actual backtesting step. This also means that ML models can be connected at many places and integrated more easily.
Last but not least, VBT was build with parameter optimization in mind: even large spaces of parameters can be tested in the blink of an eye, allowing quants to build dashboards and explore how even a tiny change in parameters impacts the overall performance, in real time!
Example
Pull the daily history of the BTC/USDT and ETH/USDT pairs from Binance, backtest 20k configurations of the MACD indicator in the most RAM-friendly manner, and visualize the win rate as a function of the MACD parameters, in less than 30 seconds
from vectorbtpro import *
@vbt.chunked(chunk_len=1000) # (1)!
def pipeline( # (2)!
data,
fastp: vbt.Chunked,
slowp: vbt.Chunked,
signalp: vbt.Chunked
) -> "concat":
macd = vbt.talib("MACD").run(data.get("Close"), fastp, slowp, signalp)
entries = macd.macd_above(0) & macd.macd_above(macd.macdsignal) # (3)!
exits = macd.macd_below(0) | macd.macd_below(macd.macdsignal) # (4)!
pf = vbt.Portfolio.from_signals(data, entries, exits, freq="d")
return pf.trades.win_rate
btc_data = vbt.BinanceData.pull(["BTCUSDT"]) # (5)!
eth_data = vbt.BinanceData.pull(["ETHUSDT"])
param_product = vbt.combine_params( # (6)!
dict(
fastp=vbt.Param(np.arange(4, 31)),
slowp=vbt.Param(np.arange(4, 31)),
signalp=vbt.Param(np.arange(4, 31))
),
build_index=False
)
btc_win_rates = pipeline(btc_data, **param_product) # (7)!
eth_win_rates = pipeline(eth_data, **param_product)
win_rates = pd.concat((btc_win_rates, eth_win_rates)) # (8)!
win_rates.vbt.volume( # (9)!
slider_level="symbol",
trace_kwargs=dict(
colorscale="icefire",
colorbar=dict(title='win_rate', tickformat='.0%'),
cmid=0.5
),
).show()
- Use chunking to reduce RAM consumption. Process at most 1000 parameter combinations at a time.
- Create a pipeline that returns the win rate for each parameter combination
- Enter a position whenever the MACD line is above zero and the signal line
- Exit the position whenever the MACD line is below zero or the signal line
- Fetch both datasets separately to avoid NaNs
- Generate 27 * 27 * 27 = 19683 parameter combinations. Since fast and slow periods are conditionally bound, we could (and should) have filtered out the combinations where the fast period is longer than the slow period, but this would only colorize a half of the cube.
- Win rates of each chunk get concatenated into a single series
- Concatenate both series. They can still be destinguished by the index level "symbol".
- Plot a cube by making a slider out of the index level "symbol" and using three other index levels (our period parameters) as the X, Y, and Z axis.
Click on the "Dashboard" tab to see the graph. May take a few seconds to render.
What about overfitting? VectorBT PRO supports various cross-validation schemes and robustness tests to bring any backtest closer to reality. We don't recommend blindly selecting the best parameter set though: the main utility of this tool is to gain understanding of why a certain set of parameters yields a certain performance - we want you to advance as a quant after all.
What are prerequisites?¶
VectorBT PRO is not your average backtesting framework: instead of defining the entire logic in a single place and only having to deal with a limited set of commands supported by the framework, vectorbtpro is an open-end tool that forces you to adopt the data science approach to backtesting, that is, working with arrays, using third-party Python packages, building complex visualizations, and analyzing all kinds of artifacts along the way - a sometimes steep learning curve.
With great freedom comes great responsibility, and so at least some knowledge of Python and scientific computing is required. But even if you have neither, no need to worry: we'll help you through tutorials, documentation, and our vibrant community
How to get access?¶
Become a member and select the plan adequate to your needs.
VectorBT PRO is hosted as a private GitHub repository. All new features are developed as part of this repository, which means that they are immediately and exclusively available to all eligible sponsors, as they are made collaborators of this repository.
-
Screen capture of the private repository
Eligible sponsors are also entitled to become members of a private Discord server to receive the latest announcements, get support, vote on feature requests, and participate in discussions.
-
Screen capture of the private Discord server