Augmented Dickey-Fuller (ADF)
Calculate the Augmented Dickey-Fuller (ADF) test for a unit root, per asset.
The test regresses the first difference of the series on its own lagged level and p lags of its own first difference. The null hypothesis is that the series has a unit root (is a random walk, not mean-reverting); the alternative is that it is stationary. This is a standard first step before modeling a price series or spread with mean-reverting methods, since those methods assume stationarity.
For more information about the method, see the following paper:
- Dickey, D.A. and Fuller, W.A. (1979). “Distribution of the Estimators for Autoregressive Time Series with a Unit Root.” Journal of the American Statistical Association, 74(366a), 427-431.
Also known as: ADF test, unit root test, stationarity test.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Augmented Dickey-Fuller (ADF) for you. Just ask in plain English.
Calculate the Augmented Dickey-Fuller (ADF) in Python
The Augmented Dickey-Fuller (ADF) is available in the Econometrics module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_augmented_dickey_fuller as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AMZN", "TSLA"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2019-01-01",
end_date="2023-12-31",
)
toolkit.econometrics.get_augmented_dickey_fuller(period="quarterly")
Which returns:
| AMZN | TSLA | |
|---|---|---|
| ADF Statistic | -7.1569 | -2.2371 |
| P-Value | 0 | 0.1931 |
| Lags Used | 8 | 8 |
| Observations | 11 | 11 |
| Critical Value 1% | -4.2232 | -4.2232 |
| Critical Value 5% | -3.1894 | -3.1894 |
| Critical Value 10% | -2.7298 | -2.7298 |
| Reject Unit Root (5%) | 1 | 0 |
Parameters
get_augmented_dickey_fuller accepts the following parameters:
- period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
- column (str, optional): The historical data column to test. Defaults to “Adj Close”.
- max_lag (int, optional): The maximum number of lagged differences to consider. Defaults to the Schwert (1989) rule of thumb.
- regression (str, optional): Which deterministic terms to include, one of “n” (none), “c” (constant) or “ct” (constant and trend). Defaults to “c”.
- include_benchmark (bool, optional): Whether to include “Benchmark” among the assets tested. Defaults to False.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.
Related Unit Root & Stationarity
The Econometrics module page introduces the module, and the sidebar lists all of its functions.