Anatolyev-Gerko Test
The Anatolyev-Gerko Test (Anatolyev and Gerko, 2005) weighs every sign by the size of the return: it is the excess return of going long when the forecast is positive and short when it is negative over that of the same share of long positions held at random. It asks whether the forecast would have made money, which the Pesaran-Timmermann Test does not.
The formula for the Anatolyev-Gerko Test starts from the average return A of a position that is long when the forecast \(\text{Forecast}_{t}\) is positive and short when it is negative, over the n periods with returns \(\text{Return}_{t}\):
\[A = \frac{\sum_{t=1}^{n} \operatorname{sign}\left(\text{Forecast}_{t}\right) \cdot \text{Return}_{t}}{n}\]B is the return expected from the same share of long positions held at random, the average position times the average return:
\[B = \operatorname{mean}\left(\operatorname{sign}\left(\text{Forecast}\right)\right) \cdot \operatorname{mean}\left(\text{Return}\right)\]The variance of the difference under the null hypothesis follows from the share of long positions p and the variance of the returns:
\[p = \frac{1 + \operatorname{mean}\left(\operatorname{sign}\left(\text{Forecast}\right)\right)}{2}\] \[V = \frac{4 \cdot p \cdot (1 - p) \cdot \sum_{t=1}^{n} \left(\text{Return}_{t} - \operatorname{mean}\left(\text{Return}\right)\right)^{2}}{n^{2}}\]The statistic is the excess return over its standard deviation:
\[\text{Anatolyev Gerko Statistic} = \frac{A - B}{\sqrt{V}}\]It is standard normal under the null hypothesis, and the p-value is one-sided, with Phi the standard normal distribution function:
\[\text{P Value} = 1 - \Phi(\text{Anatolyev Gerko Statistic})\]A positive statistic with a p-value below the significance level means the forecast’s long and short positions earned more than random positions would have. The excess return is before trading costs, and a few large returns can decide it.
A directional accuracy test asks whether a return forecast predicts the direction of the next return better than chance: the null hypothesis is that the forecast and the return are independent, the one-sided alternative that the forecast gets the direction right more often (or, weighted by size, earns more) than chance. A forecast that is right about the sign more than half of the time is not necessarily useful: in a rising market a forecast that is always positive is right on most days. These tests compare the forecast with what an uninformed forecast with the same share of positive calls would achieve. The forecast is by default time-series momentum (Moskowitz, Ooi and Pedersen, 2012), the average of the w returns before period t, a year of returns by default:
\[\text{Forecast}_{t} = \frac{\sum_{i=1}^{w} \text{Return}_{t-i}}{w}\]Every forecast only uses the returns before it. A p-value below the chosen significance level (such as 0.05) means the forecast predicts the direction better than chance; a higher p-value means no such skill is found.
Also known as: AG test, excess profitability test, trading test of predictability.
In the Finance Toolkit this is get_directional_accuracy_test with method="anatolyev_gerko", the same function as Directional Accuracy Test.
Example · QQQ, TLT, GLD, USO · 2010 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_directional_accuracy_test:
from financetoolkit import Toolkit
toolkit = Toolkit(
["QQQ", "TLT", "GLD", "USO"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2010-01-01",
end_date="2025-12-31",
)
toolkit.econometrics.get_directional_accuracy_test(method="anatolyev_gerko", period="monthly", window=12)
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The data frequency for returns (daily, weekly, monthly, quarterly or yearly). Defaults to “daily”. | "weekly" |
method | str | The test. Options are: “pesaran_timmermann” (Pesaran-Timmermann Test, the share of correct signs), “anatolyev_gerko” (Anatolyev-Gerko Test, the excess return of trading the signs). Defaults to “pesaran_timmermann”. | "pesaran_timmermann" |
forecast | str | The return forecast. Options are: “momentum” (the mean of the previous window returns), “autoregressive” (the rolling AR(1)). Defaults to “momentum”. | "momentum" |
window | int | None | The number of returns of every forecast window, at least 2. Defaults to None, which uses a year of observations with a minimum of 20 (252 daily, 52 weekly and 20 monthly, quarterly or yearly returns). | 20 |
include_benchmark | bool | Whether to include “Benchmark” among the assets tested. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | QQQ | TLT | GLD | USO |
|---|---|---|---|---|
| Anatolyev-Gerko Statistic | 0.3523 | 0.3659 | 1.3365 | 0.3972 |
| P-Value | 0.3623 | 0.3572 | 0.0907 | 0.3456 |
| Directional Accuracy | 0.6313 | 0.4581 | 0.5475 | 0.4637 |
| Observations | 179.0000 | 179.0000 | 179.0000 | 179.0000 |
4 rows
Using Your Own Data
get_directional_accuracy_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:
from financetoolkit import Economics, Econometrics
economics = Economics(start_date="2000-01-01")
unemployment = economics.get_unemployment_rate(
countries=["United States", "Germany"], period="monthly"
)
econometrics = Econometrics(data=unemployment, changes="difference")
econometrics.get_directional_accuracy_test()
References
- Paper Anatolyev, S. and Gerko, A. (2005). “A Trading Approach to Testing for Predictability.” Journal of Business & Economic Statistics, 23(4), 455-461.
- Paper Moskowitz, T.J., Ooi, Y.H. and Pedersen, L.H. (2012). “Time Series Momentum.” Journal of Financial Economics, 104(2), 228-250.
- Library Referenced against rugarch (R)’s DACTest (Pesaran-Timmermann Test, Anatolyev-Gerko Test)