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)

Which returns:

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)
Share