Z-Score Mean Reversion

← strategies

Strategy

Methodology

This strategy is backtested on daily OHLCV price data across major US equity indices and ETFs. Entry and exit signals are generated from the strategy's indicators with no lookahead bias — trades execute at the open of the bar following the signal.

Performance metrics are computed per symbol and shown individually. The parameter optimization section (where available) runs a grid search over the strategy's key parameters, optimizing for Sharpe ratio. Transaction costs and slippage are not modeled.

The signal logic and indicator code for this strategy is shown in the methodology code section below.

Methodology

Computes the Z-score of price relative to its rolling mean and standard deviation. Enters long when Z-score drops below -2 (statistically oversold), exits when it rises above +2. Assumes prices revert to their mean.

Implementation

class ZScoreReversion(Strategy):
    n = 20

    def init(self):
        self.z = self.I(_zscore, self.data.Close, self.n)

    def next(self):
        if self.z[-1] < -2 and not self.position:
            self.buy()
        elif self.z[-1] > 2 and self.position:
            self.position.close()

Performance metrics

Total return+33.850%
Net profit$338,498
Gross profit$695,194
Gross loss$369,717
CAGR+8.218%
Annualized return+8.218%
Monthly average return+0.677%
Median monthly return+0.161%
Best month return+6.520%
Worst month return-6.319%
Rolling 1-month return+11.030%
Return per trade+1.891
Log return CAGR+6.080%
Compounded vs simple return difference-31.587%

Equity curves

Chart for symbol:

Charts & distributions

2024-06 → 2026-04 · 5-year daily data

Equity curve vs ^GSPC — buy/sell signals

Strategy equityIndex (normalized)▲ Buy▼ Sell

18 trades · green dashes = buy entries · red dashes = sell exits

Drawdown (underwater)

Rolling 1-month Sharpe

Rolling 1-month return (%)

Period return (≈ monthly)

Return distribution (bar returns)

MAE vs MFE (trades)

Rolling 12m Beta

Rolling 12m correlation

Monthly returns (run)

Performance Matrix

Total return+47.614%
Net profit$476,140
Gross profit$865,200
Gross loss$416,730
CAGR+12.424%
Annualized return+12.424%
Monthly average return+0.965%
Median monthly return+1.887%
Best month return+10.593%
Worst month return-8.108%
Rolling 1-month return+16.887%
Return per trade+2.193
Log return CAGR+5.122%
Compounded vs simple return difference-45.612%