Skip to main content
Back to Tutorial
AdvancedCryptoArbitrage12 min readUpdated 2026-03-02

BTC/ETH Pair Trade · stat-arb with a Kalman filter

Classic cointegration trading on the crypto majors, with a dynamic hedge ratio and funding-aware position sizing. Demonstrates why static OLS hedging fails.

Pair trading looks simple in papers and is deceptively hard in practice. This template is the minimum viable implementation that actually handles the regime shifts in the hedge ratio.

Fork the template to follow along:
TemplateCryptoArbitrage
BTC/ETH Pair Trade

Kalman-filtered stat-arb on ETH/BTC ratio, perp execution

Sharpe
2.31
Return
+38.2%
Max DD
−8.4%
Forks
212

Why this works

ETH and BTC share a dominant common factor (crypto beta) but diverge on narrative cycles (L1 flows, ETF events). The Kalman filter captures the drift in their hedge ratio — a static OLS regression breaks within weeks because the cointegration relationship is time-varying. Pair trading is the first strategy where you really have to take funding and basis seriously.

Common pitfalls

  1. Using OLS hedge ratio refit monthly. The ratio drifts intra-month enough to matter; Kalman is not optional here.
  2. Ignoring funding rate. On Binance perps, funding can flip your expected edge sign within hours during regime breaks.
  3. Over-leveraging. 3x is the teaching ceiling — above that, liquidation during basis shocks eats tail risk.

Try it yourself

Fork the template into your workspace. The entire configuration — code, parameters, backtest window, cost model — lands in a new private session. Tweak it, break it, and see how robust the edge actually is.

Backtest result

Sharpe
2.31
Return
+38.2%
Max drawdown
−8.4%
Win rate
+64.9%
Trades
88
Days
365

Equity curve

Strategy
Benchmark

Hedge ratio updated daily via Kalman state. Enter when spread z-score > ±2, exit at 0. Funding rate subtracted from expected edge. No leverage above 3x.

Ready to learn?

Fork it into your workspace.

The whole template — code, parameters, backtest config — lands in a new private session. Tweak it, run it, break it, learn.