Vectorbt vs Backtrader
Vectorbt Vs. Backtrader
VectorBt and Backtrader are two of the largest backtesting frameworks available for Python. Both are good choices for doing backtesting work, and indeed as you improve your skills I'd recommend learning both so you can contrast between the two and improve your skillset.
For now though you might be wondering which library you should learn first.
Backtrader was first published back in 2015 by @Mementum on Github, AKA Daniel Rodriguez. For the time it had one of the most complete feature sets of any freely available backtesting framework, especially given how easy it was to use.
Unfortunately active development stopped in about 2018, with a few bug fixes being merged in here and there. A few community members have maintained a fork of Backtrader, backtrader2. In the immediate future there aren't going to be any new features added to that branch, just bugfixes to make sure it keeps running.
About the same time that development started to taper down on Backtrader, @polakowo uploaded the first few versions of what would become VectorBt. And he's still to this day hard at work building out the VectorBt ecosystem, although mostly focused on the PRO version of this library, which I'll detail a little later.
Backtrader is one of the most mature python backtesting libraries out there. As a results there's lots of material on the blog, the forums, and indeed the official documentation on how to quickly get up and running. This makes it great for diving into and quickly testing your strategies.
The syntax and overall structure should be familiar to those of you migrating from other trading/backtesting platforms. At a basic level, you create a strategy class with your trading logic. Then the data is fed into it bar by bar until you run out of data.
It's not designed for absolutely blistering speeds, rather it attempts to be easy to use. If you want a framework that's even easier to use, I'd recommend taking a look at backtesting.py.
Pros of Backtrader
- Easy to use
- Plethora of documentation
Cons of Backtrader
- No active development
- Comparatively slow at running lots of backtests
VectorBt is an extremely performant library, built almost wholly using numba-compiled components which give it blistering speeds when combined with libraries like TA-lib for optimized indicator calculation.
Because of this speed, it's also really great for optimizing your backtests by testing a wide variety of different parameters. VectorBt can often backtest 1,000 different combinations in the time it would take another library to process a single backtest.
Ultimately all of this speed comes with a cost. That being that it can take a while to get used to the library, and the documentation is currently incomplete.
It's also worth mentioning that the free version of VectorBt is no longer being actively developed, only maintained. If you want access to the latest and greatest features you'll have to pay for the PRO version, which is much easier to use overall.
Pros of VectorBt
- Very fast
- Developer is responsive to feedback
Cons of VectorBt
- Need to pay for PRO if you want the best experience
- Lack of documentation/tutorials
Overall if you're looking to migrate from a proprietary trading platform like Tradestation or Think Or Swim, I'd recommend picking up Backtrader as your first backtesting library in Python. Especially if you don't have a lot of programming experience in general. Backtrader is very quick to get up and running quickly, and implement your strategy.
If you're serious about getting the best performance out of your backtests and are willing to dive deep in the documentation, then I'd recommend VectorBt as the overall most powerful backtesting framework currently available in python. Especially if you already have some programming experience.
For ease of use go with Backtrader (or backtesting.py). For performance go with VectorBt.
If you'd prefer a video review of the two platforms, check out my youtube channel here: