Correlation Pair Bots

01 / The Idea

Stay market-neutral, always

Pair Rebalancer keeps you in a market-neutral pair trade at all times. Every 12 hours, it force-closes both legs and rebuilds fresh — using the latest β to size the hedge. Doesn't wait for divergence. Cycles on a fixed clock, like a grandfather clock for your pair trade.

In one sentence
"Rotate a hedged position on a timer, never sit flat."
02 / How it trades
  1. 1.Sets an alarm clock for every 12 hours.
  2. 2.When the alarm rings: closes whatever positions exist on both legs.
  3. 3.Recomputes β from the last 7 days of data.
  4. 4.Picks direction by spread sign (long the cheap leg).
  5. 5.Opens fresh β-weighted pair. Sleeps until next alarm. Repeat forever.
03 / Walk-through
12:00 — Cycle 1
β = 0.94, z = +0.8. Sign = positive → SHORT BTC, LONG ETH. Both legs ~$250.
+12h — Cycle 2
Bot wakes up. Closes everything. β now = 0.97, z = −0.3. Sign flipped → LONG BTC, SHORT ETH.
+1d — Cycle 3
Wakes up again. Pays round-trip fees again. Rebuilds with current β.
⚠ Every cycle costs ~0.07% in fees both legs. With 12h cycles that's ~5% / month in fees alone. β needs to drift dramatically each cycle to make this profitable.
β (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

Pair Rebalancer Parameters

time-driven
Lookback WindowHow much price history feeds the rolling β + spread distribution. Longer = more stable β, slower to adapt.
Rebalance PeriodHow often the bot force-closes both legs and rebuilds the position
Direction LogicDetermines which leg to long / short on each rebalance
If signal fires now
next rebalance
Long
ETH
$500 notional
Short
BTC
$500 notional · β-weighted

How Pair Rebalancer executes

  1. Every 12 hours: compute current β + z over last 7 days
  2. Direction: use sign(z) — long whichever leg is cheap
  3. Flatten: close existing positions on both legs
  4. Rebuild: open new β-weighted pair with fresh sizing
⚠ This bot trades the calendar, not divergence. Round-trip fees compound — only viable when fees are minimal or β shifts dramatically each cycle.
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
Pair Rebalancer · BTC / ETH
$500 capital·2x lev·MAINNET·rebalance every 12 hours
Connect wallet to deploy
Cancel