Does your Freqtrade backtest survive real trades?
Freqtrade fills every backtest order at the price it asked for. Replay the backtest's orders against the trades that followed and see what its return becomes.
Why it happens
Freqtrade's backtesting fills each entry at the candle's open, fills an order at exactly the price it asked for whenever that price is inside the candle's range, and exits a stop-loss exactly at the stop. Its documentation says so plainly: there is no slippage in a backtest. A market order in a real market pays the prices of the trades that come after it, on its side of the book, until its size is covered.
The export Freqtrade writes after a backtest has what you need to check that: every trade's pair, entry and exit time, the prices Freqtrade assumed, the amount and whether it was a short. Turn each trade into two market orders (in and out), replay them against Binance's public trade archive, and compare. Fees and funding stay exactly as Freqtrade charged them, so whatever changes is the fills.
Two things to know. For stop-loss and ROI exits, Freqtrade records the candle, not the moment inside it, so the replay prices a market order at that candle's time. And the replay assumes your order would have got the prices other takers got: it doesn't model order book depth or queue position.
Fix it with plain pandas
import json
import zipfile
import numpy as np
import pandas as pd
# A Freqtrade backtest result: recent versions write a .zip with the result JSON inside
with zipfile.ZipFile("backtest-result-2026-09-30_12-00-00.zip") as zf:
name = next(n for n in zf.namelist() if n.endswith(".json") and "_config" not in n)
result = json.loads(zf.read(name))
trades = pd.DataFrame(result["strategy"]["EmaTrend"]["trades"])
# Each trade is two market orders: in at open_rate, out at close_rate (a short sells first)
side, qty = np.where(trades["is_short"], -1, 1), trades["amount"].to_numpy()
orders = pd.concat([
pd.DataFrame({"side": side, "qty": qty, "assumed": trades["open_rate"].to_numpy()},
index=pd.to_datetime(trades["open_date"], utc=True)),
pd.DataFrame({"side": -side, "qty": qty, "assumed": trades["close_rate"].to_numpy()},
index=pd.to_datetime(trades["close_date"], utc=True)),
]).sort_index()
# ticks: that day's Binance aggTrades (price, qty, aggressor side)
def fill_from_prints(ticks, t, side, qty):
after = ticks[(ticks.index >= t) & (ticks["side"] == side)]
px, q = after["price"].to_numpy(), after["qty"].to_numpy()
before = np.concatenate([[0.0], np.cumsum(q)[:-1]])
used = np.where(before < qty, q, 0.0) # whole prints until the size is covered
return (px * used).sum() / used.sum()
ref = ticks["price"].to_numpy()[ticks.index.searchsorted(orders.index, side="left") - 1]
fill = np.array([fill_from_prints(ticks, t, s, q)
for t, s, q in zip(orders.index, orders["side"], orders["qty"])])
orders["cost_bps"] = orders["side"] * (fill - ref) / ref * 1e4 # + = worse than the last trade
print(orders[["side", "qty", "assumed", "cost_bps"]])
Or with Deptho
Deptho does all of it in one command. It reads the export (the .zip, its
.json, or the backtest_results folder for the latest one), downloads the Binance
trade days the orders need, printing the host first, and replays every order. It prints Freqtrade's return
next to the replayed one, writes a per-trade table and, with --card, a shareable image:
pip install "deptho[png]"
python -m deptho.freqtrade user_data/backtest_results --card freqtrade-cardFutures pairs like BTC/USDT:USDT map to Binance USD-M perpetuals. A spot backtest is
replayed against the perpetual of the same symbol, and the output says that this is an approximation for
spot. The free version replays the trades of the backtest's most recent 7 days, and says so when the
backtest is longer. The same from Python:
import deptho as dp
from deptho import freqtrade
orders = dp.from_freqtrade("backtest-result-2026-09-30_12-00-00.zip") # side, qty, symbol, price, ...
r = freqtrade.replay("backtest-result-2026-09-30_12-00-00.zip")
print(r.summary["freqtrade_return"], r.summary["replayed_return"], r.summary["gap_points"])
print(r.trades[["pair", "assumed_open", "replayed_open", "entry_cost_bps", "exit_cost_bps"]])
r.card("freqtrade-card") # SVG, and PNG with deptho[png]