Guides · Updated

Pairs trading explained: trading the gap between two related prices

Two related prices tend to move together. When the gap between them stretches unusually far, a pairs trade bets on it closing.

Open the pairs trading study →

The idea

Some prices are tied together: two banks in the same country, two oil producers, two funds that hold similar things. They rarely move by exactly the same amount each day, so the gap between them wanders. If the tie is real, a wide gap tends to narrow again.

A pairs trade buys the one that looks cheap and sells short the one that looks dear. It does not need the market to rise. It needs the gap to close.

How the gap is measured

First you work out how much of one offsets the other. If A usually moves 1.2% when B moves 1%, you hold about 1.2 dollars of B against each dollar of A. This is the hedge ratio.

Then you track the gap and ask how unusual today’s gap is compared with its recent average. That is measured in standard deviations, often called a z-score. A z-score of 2 means the gap is about as wide as it gets on one day in twenty.

A small example

With made-up numbers: the gap has averaged zero over the last 60 days and usually swings by 1.5% either way. Today A has fallen behind and the gap is −3%, a z-score of −2. The rule buys A and sells B short. If the gap returns to its average, the trade gains about 3% on the amount at work, before costs, whichever way the market moved in the meantime.

How it fails

A pairs trade loses when the relationship changes. One company wins a contract, is taken over, or runs into trouble, and the gap keeps widening instead of closing. The uncomfortable part is that a broken pair looks exactly like a great opportunity: the gap is wider than it has ever been.

Short selling adds its own costs and risks. You pay a fee to borrow the shares, the lender can ask for them back, and losses on a short position are not capped.

How to test it fairly

What the study on this site does

The Research Lab study does each of those steps and shows the result for two practice pairs: one whose gap keeps closing, and one that comes apart late in its history. Both practice pairs are simulated. To test a real pair you add two price files of your own.

Common questions

Is pairs trading market neutral?
It aims to be. Because it holds one investment and sells short a related one, a general rise or fall in the market affects both sides. It is still exposed to anything that affects one of the two and not the other.
What is cointegration?
Two prices are cointegrated when the gap between them, after scaling one by the hedge ratio, keeps returning to an average instead of drifting away for good. It is a stricter condition than correlation: two prices can rise together for years while the gap between them steadily widens.
What is a walk-forward test?
It is a way of testing a rule the way it would have been used. You choose settings using only past data, apply them to the next stretch of time, then move forward and repeat. Every tested period comes after the data used to prepare for it.

Try it

Reading about a rule is not the same as watching it run. The study is free, needs no account, and starts on practice data.

Open the pairs trading study →

More guides

Educational explanation with illustrative examples. Not financial advice, and not a recommendation to use any strategy.