Class CointegrationTest

java.lang.Object
com.quantfinlib.hedging.CointegrationTest

public final class CointegrationTest extends Object
Engle-Granger two-step cointegration test: regress one price series on the other, then run an augmented Dickey-Fuller test (no constant) on the residual spread. This is the statistical justification PairsHedger needs before a pairs trade — a high return correlation is not enough; the spread must be stationary.

Critical values are the Engle-Granger two-variable, no-trend asymptotics: -3.90 (1%), -3.34 (5%), -3.04 (10%). More negative ADF t-statistics mean stronger evidence of cointegration.

  • Field Details

  • Method Details

    • engleGranger

      public static CointegrationTest.EngleGrangerResult engleGranger(double[] pricesA, double[] pricesB)
      Full Engle-Granger test of prices A against prices B.
    • adfTStatistic

      public static double adfTStatistic(double[] series)
      Dickey-Fuller t-statistic (no constant, no lags — appropriate for mean-zero regression residuals): regress Δe_t = γ e_{t-1} + u_t and return t = γ̂ / se(γ̂).