Language
Search

Backtesting Tools Compared: What Separates Vectorbt, Backtrader and Freqtrade

어둠 속을 흐르는 부드러운 빛의 결을 담은 장노출 사진

·

Views 18
How do you choose a backtesting tool?
The nature of the strategy and what comes next decide it. If you need to sweep thousands of parameters fast, Vectorbt with its vectorised computation; if order and position logic is complex enough to need event-by-event handling, Backtrader; if you plan to move straight to live trading after validation, Freqtrade, which includes the bot.

The question of which backtesting tool to use is really “what kind of strategy are you validating” and “what will you do after validating it.” Settle those two and the choice follows almost automatically.

And there is something more important than the tool: the errors that make backtest results meaningless. Without knowing them, any tool will hand you a spectacular equity curve and real losses at the same time. That comes after the tool comparison.

The character of the three tools

Vectorbt — speed and parameter search

It places the whole price series in arrays and computes with vector operations in one pass — fundamentally different from looping candle by candle. That makes it overwhelming for running thousands of parameter combinations at once.

import vectorbt as vbt

price = vbt.YFData.download("BTC-USD").get("Close")

# RSI 임계값 조합을 한 번에 탐색
rsi = vbt.RSI.run(price, window=[7, 14, 21])
entries = rsi.rsi_crossed_below(30)
exits = rsi.rsi_crossed_above(70)

pf = vbt.Portfolio.from_signals(price, entries, exits, fees=0.001)
print(pf.total_return())

The weakness shows when logic gets complex. Sequential dependencies such as “change the next order size based on the previous position’s P&L” are hard to vectorise. It suits simple signal-based entry and exit strategies best.

Backtrader — the event-driven standard

It walks candle by candle, calling your strategy code each time. Because the flow of time matches real trading, complex order logic can be expressed directly. Limit orders, stop losses, trailing stops, scaled entries and per-position management all come naturally.

import backtrader as bt

class RsiStrategy(bt.Strategy):
    params = dict(period=14, low=30, high=70)

    def __init__(self):
        self.rsi = bt.indicators.RSI(period=self.p.period)

    def next(self):
        if not self.position and self.rsi < self.p.low:
            self.buy()
        elif self.position and self.rsi > self.p.high:
            self.close()

The weakness is speed. Being a Python loop, it is unsuited to sweeping large numbers of parameters. Plenty of material and examples make it easy to learn, which is a real advantage.

Freqtrade — from backtest to live trading

It is not a backtesting framework but a trading bot. Backtesting, parameter optimisation, paper trading and live trading live in one tool, with operational pieces like exchange connectivity and Telegram alerts included.

freqtrade download-data --exchange binance -t 1h --days 365
freqtrade backtesting --strategy MyStrategy --timerange 20250101-20260101
freqtrade hyperopt --strategy MyStrategy --hyperopt-loss SharpeHyperOptLoss

The strength is that the backtest and live code are the same, so there is no mismatch introduced when transcribing a validated strategy. The weaknesses are having to follow the framework’s structure, and its specialisation in cryptocurrency.

Which to use

Situation Choice
Sweeping thousands of parameters, validating ideas fast Vectorbt
Complex order and position logic, or learning Backtrader
Straight to live trading after validation, operations included Freqtrade
Several assets and markets together Backtrader or Vectorbt

In practice a combination is common: narrow the candidate parameter region with Vectorbt, then re-validate those results in Freqtrade or Backtrader under realistic fee and slippage conditions.

What makes a backtest meaningless

More important than the tool.

1. Lookahead bias

Using information that was not knowable at that moment. The most common and the most fatal.

  • Making a trading decision on the close of a candle that has not finished
  • Normalising an indicator using data from the whole period
  • Testing the past using only currently listed instruments (survivorship bias)

The symptom is clear: an unrealistically smooth equity curve. When backtest returns look too good, the strategy is far more likely to be a bug than a triumph.

2. Missing costs

  • Trading fees: charged on both the buy and the sell. The more frequent the trading, the more fatal
  • Slippage: you do not get filled at the price you wanted. Large in illiquid instruments
  • Futures funding: on perpetual futures, holding a position costs continuously. Leave it out and the results of a long-hold strategy change entirely

A backtest run with zero fees is not validation but imagination.

3. Data quality

  • Historical data from exchange APIs has missing candles
  • Prices differ between exchanges. The backtest exchange and the live exchange have to match
  • Excluding delisted coins from a test flatters the results (survivorship bias)

4. Overfitting

Sweeping thousands of parameters and picking the best combination is itself dangerous. The combination that fit the past best generally does not fit the future. The minimum defence is splitting the period: optimise on the earlier period and validate on the later period, data you have never looked at. If performance collapses on the later period, that is overfitting.

The order to start in

  1. Sweep the idea quickly with Vectorbt — just see whether there is anything there
  2. Put in realistic fees, slippage and funding and run it again — most ideas die here
  3. Take the survivors and check them split into training and validation periods
  4. Validate in a live environment with paper trading
  5. Only then live trading with a small amount

⚠️ Investment decisions and any losses are entirely your own responsibility. This article compares tools and guarantees no particular strategy or return. Backtest performance does not guarantee future returns, and cryptocurrency is extremely volatile.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *