Correlation Pair Bots

01 / The Idea

Bet on prices snapping back together

BTC and ETH usually move together — they're both crypto, both react to BTC dominance, both follow risk-on / risk-off cycles. When their price ratio drifts unusually far from normal, Spread Hunter bets it'll snap back. It buys the cheap one and shorts the expensive one. When they reconverge, both close — pocketing the gap.

In one sentence
"Trade the divergence between two correlated coins."
02 / How it trades
  1. 1.Watches the spread between BTC and ETH every minute.
  2. 2.Stays flat (no positions) when the spread is normal.
  3. 3.When the spread drifts 2.0σ from normal — opens both legs at once. β-weighted hedge keeps you market-neutral.
  4. 4.Holds until the spread reverts to 0.5σ (win) or breaks past 3.5σ (regime broke, get out).
  5. 5.Time-stop after 2 days — if it hasn't reverted by then, cut losses.
03 / Walk-through
Day 1, 09:00
ETH normally trades at ~0.038 BTC. z = 0.4. Bot stays flat.
Day 3, 14:00 — Signal
ETH crashes faster than BTC. Ratio = 0.0335 BTC, z = −2.1. ETH looks cheap.
→ LONG ETH $250 · SHORT BTC $250 (β-weighted)
Day 5, 21:00 — Exit
Ratio recovers to 0.0378 BTC, z = +0.3. Bot closes both legs. Profit captured from the gap.
💡 The trade made money even though both coins might have moved up or down — only the relative move matters.
β (beta)
How much the hedge leg moves for each $1 of base. β=2 means short 2× the hedge to stay neutral.
z-score
How many standard deviations the spread is from its mean. ±2 = unusual, ±3 = rare, ±4 = regime break.
spread
log(BTC) − β·log(ETH). When this is unusually high or low, the pair is "stretched".
correlation
How tightly the two coins move together. >0.7 = strong, <0.5 = decoupling, time to stop trading the pair.

Live Spread

BTC/
ETH
1h candles · 7 days window
NEUTRAL BAND
z-score
+
0.00
β (hedge)
OLS
1.000
correlation
weak
0.00
bars
hourly
Price Ratio
Loading spread data…
Entry ±2.0σ
Open hedged position
Exit ±0.5σ
Close — spread reverted
Stop ±3.5σ
Regime broke — flatten
Lookback 7 days
Rolling β window
PairBoth legs trade as a single market-neutral position
CapitalTotal USDC committed across both legs
$
LeverageApplied to each leg's notional
Notional / leg
$500
β-weighted hedge
$500
Total notional
$1,000

Spread Hunter Parameters

z-score gated
Lookback WindowHow much price history feeds the rolling β + spread distribution. Longer = more stable β, slower to adapt.
Entry |z|Open when |z-score| crosses this threshold
Exit |z|Close when spread reverts to this band
Stop |z|Hard stop — assume regime broke if z exceeds this
Max HoldForce-close if position stays open longer than this — even if z hasn't reverted
If signal fires now
flat
Long
ETH
$500 notional
Short
BTC
$500 notional · β-weighted

Risk Filters

block entries during regime breaks
Min CorrelationSkip new entries if rolling correlation drops below this
current: 0.00

How Spread Hunter executes

  1. Every minute: fetch 1h closes for BTC + ETH from Hyperliquid (last 7 days)
  2. OLS β: regress log(BTC) on log(ETH) over 7 days window
  3. Spread: log(BTC) − β·log(ETH)
  4. Z-score: (spread − μ) / σ
  5. Entry: if FLAT and |z| ≥ 2.0 and filters pass → open β-hedged pair
  6. Exit: close on |z| ≤ 0.5 (mean reversion), |z| ≥ 3.5 (stop), or held ≥ 2 days (time stop)
Both legs sent in parallel as IOC market orders. If only one fills, the other is reversed immediately to stay flat.
Cointegration is not guaranteed

Pairs that were historically cointegrated can decouple permanently (regime breaks, listings, hard forks). Both bots flatten on stop-out. Run on testnet first, monitor correlation closely.

Ready to deploy
Spread Hunter · BTC / ETH
$500 capital·2x lev·MAINNET·z-entry 2.0σ → exit 0.5σ → stop 3.5σ
Connect wallet to deploy
Cancel