Strategies · Mean reversion
Pairs trading: rules, a backtest and the pair that broke
How pairs trading works, with exact rules and a backtest with costs on four well-known stock pairs. Coca-Cola and PepsiCo, the textbook pair, lost 17% in two years.
On this page
Pairs trading takes two stocks that usually move together and bets that a gap between them will close. When one runs ahead of the other, the trader sells the leader short and buys the laggard in equal dollar amounts. If the gap closes, the trade gains whichever way the market went, because one side is long and the other short.
It is the classic "market-neutral" strategy, and the classic example is Coca-Cola and PepsiCo. This lesson states one common version of the rule exactly and tests it on four well-known pairs, with costs. The headline result is a loss: over the two years tested, Coca-Cola rose steadily against PepsiCo, the gap never closed, and the rule lost 17.2%. The other three pairs were roughly flat. Both outcomes teach something about what this strategy needs in order to work.
The idea
Two companies in the same business face the same costs, customers and economy, so their shares tend to rise and fall together. Divide one price by the other and the result, the price ratio, often wanders around a level for long stretches. A pairs trade bets on the wandering: when the ratio is unusually high, the first stock is "expensive against" the second, and the bet is that the ratio falls back.
Holding one stock long and the other short in equal dollars removes most of the market's direction from the result. If both fall 10%, the long loses and the short gains about the same. What is left is the change in the ratio, which is the only thing the trader has a view on.
What the bet assumes is that the relationship is stable. A ratio can also move because one company is doing better than the other, and then it does not come back. The statistics look identical at the start.
Measuring the gap
ratio = price of A ÷ price of B (the test uses its logarithm)
z-score = (ratio − average of the last 60 ratios) ÷ standard deviation of those 60 ratios
A z-score of +2 says the ratio is two standard deviations above its 60-day average: stock A is unusually expensive against stock B, by the standard of the last three months.
The rules
Checked once a day, at the close, for a pair A and B:
- Compute the z-score of the ratio over the last 60 trading days.
- If no trade is open and the z-score is +2 or higher, sell A short and buy B, half the capital on each side.
- If no trade is open and the z-score is −2 or lower, buy A and sell B short, half the capital on each side.
- Close both sides when the z-score returns to zero (crosses its average).
- One trade at a time. There is no stop-loss in the basic rule.
A worked example
On October 10, 2025 the ratio of Coca-Cola to PepsiCo closed at 0.4467 and its z-score was −2.72: Coca-Cola was unusually cheap against PepsiCo. The rule bought Coca-Cola and shorted PepsiCo. Twelve trading days later, on October 28, the ratio was 0.4674 and the z-score had crossed zero. The rule closed both sides for a gain of 2.1% on the capital after costs. The ratio rose 4.6%, and half of the capital was on each side, so the pair earned about half of that move.
What the backtest shows
The test, stated in full so it can be checked:
- Data. Daily closes of Coca-Cola (KO) and PepsiCo (PEP) from November 18, 2024 to November 17, 2026. The first 60 days build the first z-score, so trading runs from February 14, 2025: 442 trading days.
- Trading. Signals and trades use the same day's close. Half the capital is long and half short; a day's result is half the difference between the two stocks' returns, as if the two sides were reset to equal size each day.
- Costs. 0.10% of the amount traded on each side when opening and again when closing.
- Left out. Everything that makes shorting expensive: the fee for borrowing shares, interest on margin, and the dividends the short seller owes to the lender (both of these stocks pay regular dividends). Dividends received on the long side and taxes are left out too. The real result would be lower than shown.
- How the pairs were chosen. By reputation: four pairs of large rivals that textbooks use as examples. The academic method ranks all possible pairs by how closely they tracked each other in a formation year. This data cannot run that selection, so the test is of the trading rule on hand-picked pairs, not of the full published strategy.
| Measure | Pair rule (KO and PEP) | Holding both stocks |
|---|---|---|
| Total return | −17.2% | 23.5% |
| Return per year (CAGR) | −10.2% | 12.8% |
| Deepest fall from a peak | −20.6% | −10.5% |
| Longest time below a peak | 430 trading days | 229 trading days |
| Time in a trade | 76% | 100% |
| Trades | 6 | 1 |
| Trades with a gain | 50% | n/a |
Holding both stocks is shown for scale, but it is not a fair yardstick. A market-neutral trade does not aim to keep up with stocks; the honest comparison is with cash, and against cash the rule lost 17.2%.
The six trades tell the story:
| Opened | Side | Closed | Ratio at open → close | Result |
|---|---|---|---|---|
| February 14, 2025 | Short KO, long PEP | July 1, 2025 | 0.4803 → 0.5299 | −5.0% |
| July 14, 2025 | Long KO, short PEP | October 8, 2025 | 0.5124 → 0.4762 | −4.1% |
| October 10, 2025 | Long KO, short PEP | October 28, 2025 | 0.4467 → 0.4674 | 2.1% |
| November 6, 2025 | Short KO, long PEP | December 10, 2025 | 0.4878 → 0.4690 | 1.7% |
| February 4, 2026 | Long KO, short PEP | February 17, 2026 | 0.4655 → 0.4914 | 2.5% |
| April 29, 2026 | Short KO, long PEP | Open at the end | 0.5079 → 0.6956 | −14.7% (so far) |
The three gains closed in 8 to 23 trading days. The three losses were held for 61, 93 and 140 days. That asymmetry is typical: a gap that is going to close usually does so quickly, and the ones that do not close tie up the capital and grow.
Look at the first trade. It was closed by the rule, with the z-score back at zero, and it still lost 5.0%. The ratio did not come back down to its average. The average rose to meet the ratio, the same moving-target problem a Bollinger Band rule has.
Costs were minor: the rule lost 16.4% with no cost at all.
The two halves of the period
| Period | Pair rule | Holding both |
|---|---|---|
| February 2025 – December 2025 | −5.3% | 0.9% |
| December 2025 – November 2026 | −12.6% | 22.5% |
It lost in both halves. Most of the second-half loss is the single trade still open at the end.
Neighbouring settings on the same pair
| Setting | Total return | Deepest fall | Trades |
|---|---|---|---|
| 30-day lookback, enter at 2 | −18.6% | −21.9% | 10 |
| 60-day lookback, enter at 1.5 | −16.3% | −19.8% | 8 |
| 60-day lookback, enter at 2 | −17.2% | −20.6% | 6 |
| 60-day lookback, enter at 2.5 | −14.8% | −18.4% | 5 |
| 120-day lookback, enter at 2 | −12.0% | −16.9% | 2 |
| 60 days, enter at 2, stop at 3.5 | −17.5% | −21.0% | 10 |
No setting rescued it, including a stop that closes the trade when the z-score reaches 3.5. When the underlying relationship changes, tuning the rule does not help.
Four pairs, two tests
| Pair | Daily, 2025–2026 (60-day lookback) | Weekly, 2022–2026 (26-week lookback) |
|---|---|---|
| Coca-Cola and PepsiCo | −17.2%, 6 trades | −19.5%, 6 trades |
| ExxonMobil and Chevron | 3.4%, 8 trades | 12.0%, 6 trades |
| Visa and Mastercard | 3.6%, 8 trades | 9.2%, 6 trades |
| Home Depot and Lowe's | −4.1%, 7 trades | 3.6%, 6 trades |
The weekly test covers four and a half years of trading (the first 26 weeks build the z-score). Per year, the three pairs that gained made 2.5%, 2.0% and 0.8%, before any borrowing cost. Visa and Mastercard, two companies with nearly the same business, won all six weekly trades, and the reward for a perfect record was 2.0% a year.
That is the trade-off in one table. Pairs close enough to be safe have small gaps and small profits. Pairs with gaps large enough to matter can break.
Where it fails: the losing periods
- A relationship that changes. From May 2022 to November 2026 the Coca-Cola to PepsiCo ratio rose from 0.38 to 0.68, an 80% move in one direction. Whatever the cause, the two shares stopped behaving like a pair, and a rule that kept shorting the stronger one lost again and again: five of its six weekly trades lost.
- The open-ended loss. The trade opened on April 29, 2026 was 14.7% down at the end of the data and still open. Nothing in the basic rule limits it. A short position has no ceiling on its loss, as Short selling explained: borrowing, fees, rules and unlimited risk explains.
- Slow gaps. In both of the daily pairs that lost, the losing trades lasted from seven weeks to seven months. The capital earns nothing else while it waits.
- Thin profits against real costs. A gain of 2% a year before borrowing fees and margin interest can be negative after them. Stocks that are hard to borrow cost more, and a lender can recall the shares and force the trade closed at a bad moment.
- Crowding. Gatev, Goetzmann and Rouwenhorst reported strong profits for a simple pairs rule in US data from 1962 to 2002. Do and Faff later found the profits had declined steadily. A rule this simple, run by many funds with fast computers, leaves little for a slow version of it.
Compared with its neighbours
| Approach | Positions | Depends on | Worst case in this test |
|---|---|---|---|
| Pairs trading | One long, one short | The two stocks staying related | −17.2% on KO and PEP, still open |
| RSI(2) or band rules | Long or cash | A single price bouncing back | Described on their own pages |
| Holding both stocks | Two longs | The market and both companies | −10.5% from the peak |
How Finabase does it
Finabase has no pairs-trading tool and none of its tools place or suggest trades. What the product offers for this strategy is a way to look at the relationship.
- Chart. The chart's Compare option overlays a second symbol as a percentage change from the start of the range. The link above opens Coca-Cola with PepsiCo over two years; the gap between the two lines is the ratio drifting.
- Backtest. The Backtest tool trades the signals of indicators on one symbol, $10,000 per signal with no trading cost. It can go long and short on that one symbol, but it cannot hold two symbols against each other, so it cannot run a pair.
- Strategy. The Strategy tool compares indicators and prices, each side of a condition naming its own symbol, and replays two years, but it only buys. It has no short side, and a pairs trade without the short is just a bet on one stock.
Frequently asked questions
Is pairs trading risk-free because it is market-neutral?
No. Market-neutral removes most of the market's direction, not the risk that the two stocks separate. In this test the textbook pair lost 17.2% in under two years while the stock market rose.
How are pairs chosen?
The published method measures every possible pair over a formation period, often a year, and keeps those whose prices tracked each other most closely. Many traders also require the two companies to be in the same industry. Past closeness is evidence, not a promise: Coca-Cola and PepsiCo tracked each other for decades.
Why did a trade lose money even though the z-score returned to zero?
Because the z-score measures distance from a moving 60-day average. If the ratio keeps rising, the average rises after it, and the z-score falls to zero without the ratio coming down. The first trade in the test closed that way at a 5.0% loss.
Does a stop-loss fix the divergence problem?
It caps a single loss and creates more of them. With a stop at a z-score of 3.5 the Coca-Cola and PepsiCo test made ten trades instead of six and lost 17.5% instead of 17.2%.
Summary
Pairs trading shorts the stock that has run ahead and buys the one that has lagged, and gains if the gap between them closes. On four well-known pairs the rule made a few percent a year on three and lost 17% to 20% on Coca-Cola and PepsiCo, whose price ratio rose 80% in four and a half years. The gains came quickly and were small; the losses came slowly and were large, and the test does not even charge the costs of borrowing shares. The strategy's whole risk is in one assumption, that the relationship holds, and no statistic computed from past prices can confirm it in advance.
Check your understanding
5 questions on this lesson. Each answer comes with the reason, and nothing is scored.
The ratio of stock A to stock B is two standard deviations above its 60-day average. What does the pairs rule do?
- Buys A and sells B short, because A is the stronger stock
- Sells A short and buys B, in equal dollar amounts
- Buys both, half the capital each
Show the answer
B. Sells A short and buys B, in equal dollar amounts A high ratio means A is expensive against B. The rule shorts the expensive stock and buys the cheap one, betting the ratio falls back to its average.
Both stocks of a pair fall 10% on the same day. Roughly what happens to an equal-dollar pair trade?
- It loses about 10%
- It gains about 10%
- About nothing: the long side loses what the short side gains
Show the answer
C. About nothing: the long side loses what the short side gains The trade is exposed to the change in the ratio between the two prices, not to the direction of the market. That is what market-neutral means. It still loses if the two stocks move apart.
In the test, the Coca-Cola to PepsiCo ratio rose about 45% in under two years and the rule lost 17.2%. What went wrong?
- Trading costs were too high
- The gap kept widening, so the rule kept shorting the stronger stock
- The z-score was calculated over too few days
Show the answer
B. The gap kept widening, so the rule kept shorting the stronger stock The rule assumes the ratio returns to its average. When the relationship itself shifts, every short of the stronger stock loses. The result was −16.4% even with no costs, and no neighbouring setting fixed it.
Visa and Mastercard won all six weekly trades and earned 2.0% a year before borrowing costs. What does that illustrate?
- Pairs that track each other closely have small gaps, so the profits are small
- The rule should use more leverage
- A perfect win rate proves the pair is safe
Show the answer
A. Pairs that track each other closely have small gaps, so the profits are small A pair that rarely separates offers little to gain when it does. Larger gaps mean larger possible profits and a larger chance that the pair has broken. A short record of wins proves nothing about the next trade.
Which real costs does the test leave out?
- The spread on each trade
- Fees for borrowing the shorted shares, margin interest and dividends owed on the short side
- Nothing; all costs are included
Show the answer
B. Fees for borrowing the shorted shares, margin interest and dividends owed on the short side The test charges 0.10% per side for trading. A real short seller also pays to borrow the shares, pays interest on margin and owes the lender every dividend, so real results would be lower than shown.
Sources and further reading
- Evan Gatev, William N. Goetzmann and K. Geert Rouwenhorst, “Pairs Trading: Performance of a Relative-Value Arbitrage Rule,” Review of Financial Studies 19(3), 2006
- Binh Do and Robert Faff, “Does Simple Pairs Trading Still Work?”, Financial Analysts Journal 66(4), 2010 — the decline in pairs profits after the 1990s
- SEC — Key points about Regulation SHO (short sales)
- Finabase chart data — KO, PEP, XOM, CVX, V, MA, HD and LOW, daily bars November 2024 to November 2026 and weekly bars November 2021 to November 2026; rule and results computed by Finabase
