Article · 4 min read
Backtesting Crypto Futures and Judging Signals: Funding, Leverage, Liquidation
How to backtest crypto perpetual futures: funding rates, leverage, liquidation price, fees, and how to evaluate trading signals safely.
In crypto, derivatives, especially perpetual futures, make up most of the volume. Leverage lets a small account hold a large position, but it brings a risk spot trading does not have: liquidation, the forced closing of your position. That is why a backtest written for spot is misleading on futures. This article shows how to test futures strategies properly and how to read third-party signals.
Leveraged trading can lose your entire starting capital. This article is educational and not investment advice.
How futures differ from spot in a backtest
- Leverage and margin: position size is a multiple of your equity; losses are multiplied too.
- Liquidation: when price reaches a certain level the position is closed, so the strategy never gets to "wait for a recovery".
- Funding rate: on perpetual contracts, longs and shorts pay each other at fixed intervals (every 8 hours on many exchanges). A strategy that holds positions pays or earns this carry.
- Mark price vs last price: liquidation is usually based on the mark price, not the last trade, so sudden wicks behave differently.
- 24/7 market: weekends and nights are part of the strategy. For the infrastructure side, read running crypto bots 24/7.
Put the liquidation price into the backtest
A rough estimate for an isolated-margin long position (maintenance margin varies by exchange and contract; the value below is only an example):
def liquidation_price_long(entry: float, leverage: float, maint_margin: float = 0.005) -> float:
"""Approximate liquidation price for an isolated-margin long (educational)."""
return entry * (1 - 1 / leverage + maint_margin)
def liquidation_price_short(entry: float, leverage: float, maint_margin: float = 0.005) -> float:
return entry * (1 + 1 / leverage - maint_margin)
for lev in (2, 5, 10, 20):
liq = liquidation_price_long(100.0, lev)
print(f"{lev:>2}x leverage -> liquidation ~ {liq:.2f} (-{(1 - liq / 100) * 100:.1f}% from entry)")The logic: at 10x leverage an adverse move of roughly 9.5% wipes your margin; at 20x it is about 4.5%. Daily moves of 5-10% are not rare in crypto. In the backtest, if a candle's low/high touches the liquidation price, close the position in that candle; looking only at closes misses wicks and gives unrealistic results.
Add funding and fees
When the funding rate is positive, longs pay shorts. For a strategy that holds long, that is a cost:
import pandas as pd
def net_pnl(price_ret: pd.Series, position: pd.Series, funding: pd.Series,
taker_fee: float = 0.0005, leverage: float = 3.0) -> pd.Series:
"""price_ret: candle return, position: -1/0/+1, funding: per-candle funding rate (+ = longs pay)."""
gross = position.shift(1).fillna(0) * price_ret * leverage
fees = position.diff().abs().fillna(0) * taker_fee * leverage # fee when position changes
carry = -position.shift(1).fillna(0) * funding * leverage # longs pay
return gross - fees + carryThe rates are illustrative; real fees and funding depend on the exchange, your tier and the period. Rule: always show gross and net after funding and fees together. For the effect of costs see commissions and slippage in backtests.
Judging signals safely
Most sources selling "signals" on leveraged markets make the same mistakes. Before trusting one, ask:
- Is there a verifiable track record? Timestamped and immutable, or cherry-picked screenshots?
- Net or gross? Are fees, funding and slippage included?
- Is leverage stated? The same signal at 3x and 20x has completely different outcomes; liquidation risk must be part of the signal.
- Is there a stop and a position size? A signal without a stop is a signal towards liquidation.
- Does it promise guarantees? Anyone saying "sure profit" or "guaranteed X%" is a red flag.
For a general framework see the guide to reading AI signals. At ApolloHelix signals are not published until an independent, timestamped paper (simulated) validation is complete; the logic is explained in the backtesting and paper trading guide.
A safer futures testing flow
- First check whether the strategy has an edge in spot logic; leverage does not make a bad strategy good, it only magnifies losses.
- Add liquidation, funding and fees to the backtest; use intra-candle low/high.
- Move to paper at low leverage (for example 1x-3x); a testnet is ideal for this.
- If you go live, start with a small amount you can afford to lose. See the risk management guide and our leverage article.
This article is educational and not investment advice. Past results do not guarantee future performance; leveraged trading can lose all of your capital.