Trading Dev AcademyFree quant education

Free lesson · Time series

Forecast horizons, EWMA, and model diagnostics

Open interactive lessonPractice calculationsExplore labs

Start with the idea

A recursive forecast balances adaptation with stability. Fast updates react to shocks but may force costly position changes; slow updates can leave the book exposed to volatility that has already risen.

Symbols, units & horizon
  • σ̂ₜ²: variance forecast made before innovation εₜ
  • λ: EWMA weight on old variance, between 0 and 1
  • εₜ: observed residual return
  • μ: AR process mean
  • φ: AR coefficient
  • h: integer forecast horizon in periods
  • E[xₜ₊ₕ|xₜ]: expected future level given the current level
  • Hat: estimated quantity

When and why to use this

Use EWMA as a transparent volatility baseline and multi-step forecasts to align the model horizon with the actual holding period.

σ^t+12=λσ^t2+(1−λ)εt2,0<λ<1
Algebra and arithmetic

Unroll an EWMA variance forecast

  1. Substitute the previous recursion repeatedly: vt+1=λkvt+1−k+(1−λ)∑j=0k−1λjεt−j2.
  2. The weights sum to λk+(1−λ)(1−λk)(1−λ)=1. A shock’s weight halves at h=ln⁡(.5)ln⁡λ.
Work it by hand

λ=.94, old variance=.0001, shock=.02 gives .94(.0001)+.06(.0004)=.000118; next SD≈1.086%.

EWMA updates the variance forecast using the last innovation. Larger λ means slower adaptation; the weight half-life is ln(1/2)/ln(λ). Unlike stationary GARCH with an intercept, this form has no fixed long-run variance toward which the forecast reverts.

𝔼[xt+h|xt]=μ+ϕh(xt−μ)
Algebra and arithmetic

Iterate the conditional AR forecast

  1. Write xt+1−μ=ϕ(xt−μ)+εt+1. Conditional mean-zero future innovations disappear under expectation.
  2. At two steps multiply the current deviation by φ²; induction gives φʰ. Add μ back.
Work it by hand

Current spread 5, mean 3, φ=.8, horizon 2: forecast=3+.64(2)=4.28, an expected decline of .72.

For a stable AR(1), the conditional forecast converges toward μ as h grows. A negative φ alternates the sign; a half-life for absolute deviation is not a monotone price-reversion forecast. Validate residual autocorrelation, changing variance and forecast errors at the actual trading horizon.

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 ewma_variance(previous_forecast, innovation, decay=.94):
    if not 0 < decay < 1 or previous_forecast < 0:
        raise ValueError("Require variance >= 0 and decay in (0,1)")
    return decay*previous_forecast+(1-decay)*innovation**2

def ar_forecast(current, mean_level, phi, horizon):
    if horizon < 0 or int(horizon) != horizon:
        raise ValueError("Nonnegative integer horizon required")
    return mean_level+phi**horizon*(current-mean_level)

print(ewma_variance(.0001, .02), ar_forecast(12, 10, .8, 2))

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