Are Stock Prices Mean-Reverting? Augmented Dickey-Fuller Test in Python
May 14, 2026
What’s the question?
Mean reversion is the idea that asset prices tend to return to a long-run average over time. A stock that has fallen significantly will eventually recover. A stock that has risen sharply will eventually pull back. Many trading strategies depend on this assumption — pairs trading, Bollinger Band signals, and RSI-based entries all rely on prices reverting to some equilibrium.
The problem is that this assumption may not be correct. If stock prices follow a random walk — where each day’s movement is independent and the series has no tendency to return to any particular level — then mean reversion strategies are attempting to exploit a pattern that does not exist.
The Augmented Dickey-Fuller (ADF) test provides a statistical answer. It tests whether a time series contains a unit root. A unit root indicates that the series is non-stationary: it wanders freely without a fixed mean to return to. If the test rejects the unit root hypothesis (p-value below 0.05), the series is stationary — it fluctuates around a stable average, and mean reversion has a mathematical basis.
The approach
We test 6 stocks across different sectors: AAPL and MSFT (technology), XOM (energy), JNJ (healthcare), NVDA (semiconductors), and PG (consumer staples). Sector diversity is important because mean reversion, if it exists, may appear in defensive sectors but not in high-growth ones.
For each stock, we run the ADF test on two series: raw closing prices and daily returns. This distinction is central. Prices and returns have fundamentally different statistical properties, and confusing the two is one of the most common errors in quantitative strategy design.
import xfinlink as xfl
import pandas as pd
import numpy as np
from statsmodels.tsa.stattools import adfuller
xfl.set_api_key("your_key") # free at https://xfinlink.com/signup
tickers = ["AAPL", "MSFT", "XOM", "JNJ", "NVDA", "PG"]
df = xfl.prices(tickers, period="1y", fields=["close", "return_daily"])
for ticker in tickers:
t = df[df["ticker"] == ticker].sort_values("date")
adf_price = adfuller(t["close"].dropna(), autolag="AIC")
adf_return = adfuller(t["return_daily"].dropna(), autolag="AIC")
price_result = "STATIONARY" if adf_price[1] < 0.05 else "UNIT ROOT"
return_result = "STATIONARY" if adf_return[1] < 0.05 else "UNIT ROOT"
print(f"{ticker}: price_p={adf_price[1]:.4f} ({price_result}) return_p={adf_return[1]:.4f} ({return_result})")
Output:
=== Augmented Dickey-Fuller Test: Are Stock Prices Mean-Reverting? ===
Ticker Price ADF Price p Result | Return ADF Return p Result
-------------------------------------------------------------------------------------
AAPL -0.557 0.8803 UNIT ROOT | -14.469 0.0000 STATIONARY
MSFT -0.753 0.8325 UNIT ROOT | -15.126 0.0000 STATIONARY
XOM -0.491 0.8937 UNIT ROOT | -12.008 0.0000 STATIONARY
JNJ -1.327 0.6168 UNIT ROOT | -15.172 0.0000 STATIONARY
NVDA -1.424 0.5708 UNIT ROOT | -9.588 0.0000 STATIONARY
PG -1.694 0.4340 UNIT ROOT | -15.093 0.0000 STATIONARY
Prices stationary: 0/6 (expect 0 — prices follow random walks)
Returns stationary: 6/6 (expect all — returns are i.i.d.)
What this tells us
The results are consistent across every sector. All 6 price series contain unit roots. P-values range from 0.43 (PG) to 0.89 (XOM), none approaching the 0.05 rejection threshold. Stock prices do not mean-revert.
This holds even for PG — Procter & Gamble, the most stable and defensive stock in the sample. If any equity were to exhibit mean-reverting prices, a low-volatility consumer staple would be the most likely candidate. Its p-value of 0.43 confirms that the random walk property is not a function of volatility or sector. It is structural. Markets incorporate available information into prices continuously, so future price movements are driven by new information, which is by definition unpredictable. There is no fixed level for prices to return to.
Daily returns present the opposite result. Every p-value is 0.0000 — strongly stationary. Returns fluctuate around a stable mean near zero. This follows directly from the mathematical relationship between prices and returns. If prices are integrated of order 1 (a random walk), then returns — the first difference of prices — are integrated of order 0 (stationary). Differencing removes the unit root.
This duality is foundational in quantitative finance. Portfolio theory, the Capital Asset Pricing Model, factor models, and options pricing all assume stationary returns, not stationary prices. The ADF test provides empirical verification of this assumption.
So what?
A strategy that buys when price falls below a moving average and sells when it crosses above is implicitly assuming prices are stationary. The evidence above indicates they are not. The strategy may produce occasional gains, but it lacks statistical support.
Mean reversion strategies can be effective, but not on raw prices. The key is to construct derived series that are stationary: the spread between two correlated stocks in a pairs trade, the ratio of a stock’s price to its sector ETF, or the z-score of price relative to a rolling mean. These constructed series can exhibit stationarity, and the ADF test is the standard method for confirming this before committing capital.
pip install xfinlink