The permutation test

The permutation test

Running the whole optimisation again on shuffled prices, and asking the real result to beat nearly all of them.

The question it asks

An optimiser will find something to exploit in any history, even a random one. So the real question about a strategy is not "is its result good?" but "is its result better than what the same optimisation finds in a market with no pattern at all?"

How it works

  1. Run the strategy's whole walk-forward on the real prices, and keep its score.
  2. Shuffle the history: keep every move of every bar — the gap from one close to the next open, the moves from open to high, low and close, the volume — but put them in a random order. The distribution of returns is intact; any sequence a strategy could learn is gone.
  3. Run the same walk-forward, the same optimisation, on that shuffled history. Repeat many times.
  4. The p-value is the share of runs, the real one included, that score at least as well as the real one. With 19 shuffles, the real run must beat all of them to reach 5 %.

Why it complements the deflated Sharpe ratio

The deflated Sharpe ratio corrects for how many strategies were tried; the permutation test corrects for how much the optimisation of one strategy can find in noise. A strategy worth money should pass both. The method is described at length by Timothy Masters in his work on testing trading systems.

Its limits

It is expensive — each shuffle is a full walk-forward — and shuffling each market on its own loses what markets share, which makes the test slightly easier to pass than it should be.

More on the method

All guides

This page explains a trading idea and how it can be tested. It reports no result and is not investment advice.