Trading Dev AcademyFree quant education

Free lesson · Time series

Start with time order, lags and differences

Open interactive lessonPractice calculationsExplore labs

Start with the idea

  • A time series is a list with a clock.
  • A lag means an earlier entry in the same time convention.
Symbols, units & horizon
  • t: observation index with one fixed daily interval
  • xₜ: value observed on day t in units
  • xₜ₋₁: preceding daily observation
  • Δxₜ: change in units
  • mₜ: two-observation trailing mean in units

When and why to use this

Use lags to build features from available observations. Moving averages, autocorrelation and volatility recursions depend on this time indexing.

  • Use observations 10, 12, 11 at times 0, 1, 2.
  • At t=2, the current observation is x2=11.
  • The one-step lag is x1=12.
  • The difference is 11−12=−1.
  • A two-point trailing mean averages the current observation and its one-step lag.
  • Decide whether the current observation is available before using it.
Δxt=xt−xt−1,mt=xt+xt−12
Core rule · definition and worked arithmetic

Start with time order, lags and differences

  1. At the last observation, read current=11 and previous=12.
  2. Subtract: 11−12=−1 unit.
  3. Add the same observations and divide by two: (11+12)/2=11.5 units.
Work it by hand

At t=1, difference=12−10=2 and trailing mean=11. At t=2, difference=−1 and trailing mean=11.5.

Use the rule

  • Name the inputs and units.
  • Work the small example by hand.
  • Check the result before continuing to the next lesson.

Before moving on

Explain the core rule in one sentence, reproduce the worked calculation and solve both practice variations.

Research sources, review dates and limitations

Capstone checkpoint 4 / Build a causal baseline

Synthetic exercise · self-assessed. Use completed closes $98, $99 and $100 in the capstone feature walkthrough. Compute the trailing mean and relative deviation. Change a later close and check that the earlier feature stays unchanged.

Save in your practice notes: A small feature table and a future-change check. Open practice studio →

Check your reasoning

The mean is $99 and the relative deviation is about 1.0101%. This is a feature, not evidence of positive expected returns.

Full hand-working, definitions and runnable Python →

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 lag_summary(values):
    if len(values)<2: raise ValueError("Two observations required")
    current,previous=values[-1],values[-2]
    return current-previous,(current+previous)/2

print(lag_summary([10,12,11]))

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