Skip to content

Strategy pattern · Stat arb

Build a pairs trading bot that counts every pair it screens.

Super Algo Kit grades the pairs trading strategy B. It trades the spread between two economically linked instruments when the spread strays unusually far from normal, expecting it to come back. Early equity studies documented the effect, and later work found it declined as the idea spread. The kit has not tested it, and it counts every pair you screen as a trial.

strategy facts

Pairs trading on a cointegrated or closely matched spread

Family
Statistical arbitrage: relative value between linked instruments
Markets
Equities, ETFs, futures and crypto spot
Timeframes
Daily or hourly bars
Evidence grade
B: documented, with clear evidence of decline after publication
Status
Literature: published, untested by the kit
Pair selection
Economic link first, then a distance or cointegration test on formation data only
Data needed
Synchronous prices for both legs, a point-in-time universe with delistings, borrow and costs

From the kit's own card. Not investment advice.

Paper first

Test it before you trade it.

Super Algo Kit runs inside the coding agent you already use. It interviews you, writes the spec with pass marks set first, then builds, backtests and paper-tests. Real money starts only when you type the authorize command.

Type this in your coding agent
Build me a pairs trading bot for two US bank stocks with a cointegration test and a break rule on Interactive Brokers. Paper only.

The plan, step by step

Tick them off as you go.

How does a pairs trading strategy work?

Two instruments tied by economics can drift apart for a while when one side gets more buying or selling pressure. Examples include an ETF and its basket, a stock listed on two venues, or spot and its future. Arbitrageurs close the gap, and the pairs trader is paid for bearing the risk that it widens first.

Cointegration is a statistical test of that tie, and the Engle-Granger two-step method is a common way to run it. The hedge ratio between the legs is estimated on formation data only.

Pairs trading rules in plain words

Here is the outline, in summary. Thresholds and windows are declared before testing.

  • Choose candidate pairs by economic link, then by a statistical test.
  • Open the spread when it moves several standard deviations from its formation mean.
  • Close at the mean, or after a time limit.
  • Stop trading the pair if the spread breaks a wider bound or the test fails.
  • Trade both legs together, sized to the hedge ratio.

What the evidence says, and where it breaks

Pairs trading is well documented, and the kit grades it B. A 2006 study found an effect in simple distance-based equity pairs, and a 2010 follow-up asked whether it still held up. Competition has reduced simple pairs results over time.

The biggest risks are permanent breaks and false discoveries. Mergers, restructurings, index changes or new regulation can end a relationship for good. Screening thousands of pairs also finds cointegrated ones by pure chance.

How Super Algo Kit tests a pairs trading bot

Pass marks come first, and every pair screened and every parameter is logged as a trial. That count feeds the deflated Sharpe ratio and the probability of backtest overfitting, which matter most here. Formation and trading windows stay strictly separate and roll forward.

The backtest simulates both legs' fills and costs, borrow and the break rule. Costs come from the market pack, with stress runs at 2x and 3x. Pairs are never re-selected with future data.

Before you rely on it

Where it fails.

  • Permanent breaks: mergers, restructurings, index changes or new regulation end the link.
  • Selection look-ahead: pairs picked on the whole sample look perfect in the test.
  • Multiple testing: screening thousands of pairs finds cointegration by chance.
  • Legging risk: one leg fills and the other does not, leaving a directional position.
  • Competition has reduced simple pairs results over time.

FAQ

Pairs trading: questions.

What is pairs trading?

Pairs trading buys one instrument and sells a linked one when the spread between them strays unusually far from normal. The bet is that the gap closes. Super Algo Kit grades the pattern B, with clear evidence of decline after publication.

What is cointegration in pairs trading?

Cointegration in pairs trading is a statistical test of whether two prices are tied, so that their spread keeps returning toward a stable level. The Engle-Granger two-step method is a common way to run it. Super Algo Kit estimates the hedge ratio on formation data only, then tests on later data.

Is pairs trading still worth testing?

The evidence says simple pairs trading results have declined as competition grew. Super Algo Kit keeps the pattern at grade B and makes you count every pair screened as a trial. Most retail strategy ideas fail honest testing, and the kit tells you when yours does.

Why do pairs trading backtests look too good?

Pairs chosen because they were cointegrated over the whole sample look perfect in a test of that same sample. Screening thousands of pairs also finds false matches by chance. Super Algo Kit keeps formation and trading windows separate and deflates results over every pair tried.

Do I need to short sell for pairs trading?

Usually one leg of a pairs trade is a short, so borrow availability and fees matter. Super Algo Kit includes borrow and both legs' costs in the backtest. If one leg fills and the other does not, the bot holds a one-sided position, so both legs' fills are simulated.

Keep reading

More guides.

Sources the kit's card cites

  • Gatev, Goetzmann and Rouwenhorst (2006). Pairs Trading: Performance of a Relative-Value Arbitrage Rule. Review of Financial Studies.
  • Do and Faff (2010). Does Simple Pairs Trading Still Work? Financial Analysts Journal.
  • Engle and Granger (1987). Co-Integration and Error Correction: Representation, Estimation, and Testing. Econometrica.

Build it with Super Algo Kit.

15 specialist roles and 35 skills inside your coding agent. Paper first, live only when you say.

Super Algo Kit is development software. It is not investment advice, a signal service or a promise of performance. Trading involves substantial risk, including the loss of all capital you trade with.