Trading Dev AcademyFree quant education

Free lesson · Time series

Stationarity: the assumption every test makes and every market breaks

Open interactive lessonPractice calculationsExplore labs

Start with the idea

Stationarity is a property of a stochastic process across time, not a statement that a chart looks flat. A weakly stationary process has stable first and second moments; one realised sample will still fluctuate.

Symbols, units & horizon
  • xₜ: process value at observation time t
  • μ: constant mean
  • σ²: constant unconditional variance
  • γ_k: covariance at lag k
  • ∀t: for every time t
  • E, Var, Cov: expectation, variance, covariance
  • c: constant AR intercept, so μ=c/(1−φ)
  • φ: AR coefficient, absolute value below 1
  • εₜ: independent mean-zero innovation
  • σ_ε²: innovation variance
  • k: nonnegative lag in observation periods

When and why to use this

Use stationarity assumptions when fitting autoregressions and estimating dependence from repeated observations. Recheck them when a market changes its trading hours, policy regime or liquidity.

A series is (weakly) stationary if its mean, variance and autocovariances do not change over time. Almost every statistical tool — regression, correlation, t-tests, the CLT — quietly assumes this. Prices are not stationary: they wander. Returns are closer, but their variance shifts with regime.

𝔼[xt]=μ,Var⁡(xt)=σ2,Cov⁡(xt,xt−k)=γk∀t
Model-implied moment algebra

Verify moments in a stable AR model

  1. For xt=c+ϕxt−1+εt, take expectations under stationarity: μ=c+ϕμ, so μ=c(1−ϕ).
  2. With independent innovation variance σ²ε, v=ϕ2v+σε2, hence v=σε2(1−ϕ2) for |φ|<1. Iterating covariance gives γk=ϕkv for nonnegative k.
  3. The moments depend on lag k, not calendar time t. These calculations verify the definition under the model assumptions; they are not a test that a market obeys it.
Work it by hand

c=1, φ=.5, innovation variance 3 gives mean 2, variance 4, lag-one covariance 2.

This is why strategies decay. You estimated P(win|setup) on a sample from one regime. The regime changed — rates rose, volatility doubled, the market-maker population turned over — and the conditional probability you measured no longer describes the process generating today's prices. The math did not fail; its precondition did.

You regress the S&P 500 price level on the number of Netflix subscribers, 2012–2021. The R2 will be…

Both series trend upward over the decade, so a straight line through them fits extremely well. Neither causes the other. Regress the changes and the relationship vanishes. Trending (non-stationary) series make everything look related.

The standard check is the augmented Dickey–Fuller test: it asks whether the series has a unit root (a random-walk component). A small p-value rejects the unit-root null under the chosen lag and deterministic-term specification; it does not prove stable dynamics or a tradable edge. Estimated cointegration residuals require cointegration-specific critical values, not an ordinary ADF p-value.

Python implementation

Self-contained teaching example. Python 3.10+; dependencies and input conventions are shown in the code and notation. Run in your own Python environment.

def ar1_stationary_moments(mean_level, phi, innovation_variance, lag=0):
    """Stable AR(1): x_t-mu = phi*(x_prev-mu)+epsilon_t."""
    if abs(phi) >= 1 or innovation_variance < 0 or lag < 0:
        raise ValueError("Require |phi| < 1, variance >= 0, lag >= 0")
    variance = innovation_variance/(1-phi**2)
    return mean_level, variance, phi**lag*variance

print(ar1_stationary_moments(0, .8, 1, 1))

Continue learning

Time Series Analysis — all lessons
  1. Start with time order, lags and differences
  2. Before GARCH: mean, shocks and changing variance
  3. Stationarity: the assumption every test makes and every market breaks
  4. Autocorrelation: momentum, mean reversion, or coin flips
  5. GARCH: volatility clusters, and you can model the cluster
  6. Cointegration: a stationary relationship to test
  7. Forecast horizons, EWMA, and model diagnostics
  8. Markov chains: a two-state model you can calculate by hand
  9. Hidden Markov models: predict, observe, update

Quantitative finance and development glossary · Python resources and libraries · Research sources and limitations