TQBTHEQUANTBATEMAN
TQB/ learn/ equity/ realized volatilityEN · DARK
volatility · foundation

Realized volatility

Measuring path dispersion without confusing an estimator for an observable truth

BY THE END, YOU CAN

01Compute close-to-close and range-based realized-volatility estimators with explicit units.

02Derive annualization from return variance rather than memorizing a square-root rule.

03Diagnose window, sampling, jump and microstructure effects.

04Interpret a rolling estimate as a backward-looking state variable, not a forecast.

01
INTUITION

Build the state before the equation.

Realized volatility is an estimate extracted from a finite price path. The sampling clock, return definition, window and treatment of jumps are part of the number—not implementation details.

01

Prices are observed; volatility is estimated from returns.

02

Variance aggregates across independent increments; volatility inherits square-root time scaling only under stated assumptions.

03

Range estimators use intraday extremes efficiently but impose stronger path assumptions.

02
WHY MARKETS CARE

The product exists before the model.

Risk limits, variance-swap marks, volatility targeting and model validation all need an ex-post measure of dispersion that can be reproduced from a fixed dataset.

INSTRUMENTS

cash equities and indices

futures

variance swaps

volatility-controlled portfolios

QUOTE CONVENTION

This lesson reports annualized decimal volatility from log returns and an ACT/365-like clock. A displayed 20% means 0.20 in calculations.

03
MATHEMATICS

Notation, units and exact claims.

r_t = ln(S_t/S_{t-1}): log returnn: observations in the windowA: observations per yearλ: EWMA decay
QUANT NOTESYNTHETIC · EDUCATIONAL

Close-to-close estimator

Annualized sample standard deviation of equally spaced log returns.

σ^cc=A1n1t=1n(rtrˉ)2\widehat{\sigma}_{cc}=\sqrt{A\,\frac{1}{n-1}\sum_{t=1}^{n}(r_t-\bar r)^2}
Read the equation together with its financial domain and convention.
QUANT NOTESYNTHETIC · EDUCATIONAL

Parkinson range estimator

Uses the intraday high-low range and is efficient under a continuous driftless diffusion, but misses overnight jumps.

σ^P2=A4nln2t=1n[ln(Ht/Lt)]2\widehat{\sigma}_{P}^{2}=\frac{A}{4n\ln 2}\sum_{t=1}^{n}\left[\ln(H_t/L_t)\right]^2
Read the equation together with its financial domain and convention.
QUANT NOTESYNTHETIC · EDUCATIONAL

EWMA variance

A recursive state with geometrically decaying memory; the decay factor determines responsiveness.

σ^t2=λσ^t12+(1λ)rt2\widehat{\sigma}_{t}^{2}=\lambda\widehat{\sigma}_{t-1}^{2}+(1-\lambda)r_t^2
Read the equation together with its financial domain and convention.
04
DERIVATION

Do not jump to the final expression.

DERIVATION

From quadratic return variation to an annualized quote

The square-root rule follows from a variance model; it is not a universal unit conversion.

  1. 01

    Define the return clock

    Choose close-to-close log returns at a fixed sampling interval and preserve timezone, corporate-action and missing-observation rules.

    rt=lnStlnSt1r_t=\ln S_t-\ln S_{t-1}
  2. 02

    Estimate one-period variance

    Center the sample when estimating unconditional variance. For a zero-mean high-frequency model, realized variance often uses the uncentered sum.

    sr2=1n1(rtrˉ)2s_r^2=\frac{1}{n-1}\sum(r_t-\bar r)^2
  3. 03

    Derive time aggregation

    If equal-period returns are uncorrelated with common variance, the variance of their sum is the sum of variances.

    Var(i=1Ari)=AVar(r)\operatorname{Var}(\sum_{i=1}^{A}r_i)=A\operatorname{Var}(r)
  4. 04

    Convert variance to volatility

    Taking the positive square root produces annualized volatility.

    σann=Asr\sigma_{ann}=\sqrt{A}\,s_r
  5. 05

    Choose an estimator for the data

    OHLC estimators can reduce sampling noise, while EWMA deliberately weights recent shocks more heavily. Compare estimators rather than silently switching definitions.

A realized-volatility number is auditable only when its return clock, estimator, window, annualization and data cleaning are attached.

05
MODEL / PRICING

Fit, compute, then challenge the assumptions.

METHOD

Compute several estimators over the same clean path, report their definitions, and examine sensitivity to sampling and window length.

CALIBRATION

There is no option calibration. Select λ or window length through a documented forecasting or risk objective and validate out of sample.

LIMITATIONS

Backward-looking and regime dependent.

Sensitive to jumps, market closure and microstructure noise.

Square-root scaling can fail under autocorrelation or non-stationarity.

MODEL COMPARISON

Static fit is not dynamics.

QuestionBlack–ScholesLocal volatilityHeston
Volatility stateOne constant σσ(S,t) deterministicvₜ stochastic
Fits today’s surfaceNoExactly, in ideal theoryApproximately by calibration
Forward dynamicsFlat smileSpot-drivenVariance + correlation driven
Primary strengthTransparent baselineVanilla-consistent diffusionRicher smile dynamics
Primary failureNo smileOften unrealistic forward skewParameter and calibration instability
ComputeLowMedium: PDE/MCMedium–high: Fourier/PDE/MC
Hedge implicationGreeks at one σState-localized vol hedgeVariance and vol-of-vol risk
Implementation with current QuantLib

Current QuantLib separates market structures, processes, instruments, engines and calibration helpers. Use those abstractions only after the lesson’s conventions, domains and numerical checks are explicit.

API authority: upstream QuantLib reference pinned in the source registry.
06
PYTHON LAB

Theory → implementation → checks.

PYTHON 3 · NUMPY / SCIPY

Auditable realized-volatility estimators

Compute close-to-close, Parkinson and EWMA estimates from a deterministic price path.

REUSABLE EXAMPLE
01from __future__ import annotations
02
03import numpy as np
04
05def realized_vol(close: np.ndarray, periods: int = 252) -> float:
06 if close.ndim != 1 or close.size < 3 or np.any(close <= 0):
07 raise ValueError("close must contain at least three positive prices")
08 returns = np.diff(np.log(close))
09 return float(np.std(returns, ddof=1) * np.sqrt(periods))
10
11def parkinson(high: np.ndarray, low: np.ndarray, periods: int = 252) -> float:
12 if high.shape != low.shape or np.any(high < low) or np.any(low <= 0):
13 raise ValueError("invalid high-low path")
14 variance = np.mean(np.log(high / low) ** 2) / (4.0 * np.log(2.0))
15 return float(np.sqrt(periods * variance))
16
17close = np.array([100.0, 101.2, 99.8, 102.1, 101.4, 103.0])
18high = close[1:] * 1.008
19low = close[1:] * 0.992
20sigma_cc = realized_vol(close)
21sigma_p = parkinson(high, low)
22assert np.isfinite([sigma_cc, sigma_p]).all()
23assert sigma_cc > 0.0 and sigma_p > 0.0
24print(f"CC {sigma_cc:.2%} | Parkinson {sigma_p:.2%}")
EXPECTED OUTPUTDeterministic annualized close-to-close and Parkinson estimates.
SANITY CHECKS

Positive prices and ordered ranges are validated.

Sample standard deviation uses ddof=1.

Annualization is explicit.

07
INTERACTIVE LAB

Move the state. Challenge the equation.

PATH → ESTIMATOR → ANNUALIZED STATE

Estimator and regime lab

Change estimator, window and scenario; inspect the path, rolling estimate and annualization together.

SYNTHETIC · CONTROLLED SCENARIOS
Latest rolling11.00%
Peak11.00%
EWMA λ0.94
ACTIVE STATE

CalmLow dispersion with a stable state. Move the intensity control and inspect every series with pointer or touch.

08
FRONT OFFICE

Where the model meets the book.

ON THE DESK
The window is a position: it determines which regime you are carrying into the number.
VISIBLE INPUTS

adjusted OHLC path

sampling clock

window

annualization basis

jump and missing-data policy

CALIBRATION

There is no option calibration. Select λ or window length through a documented forecasting or risk objective and validate out of sample.

RISK

estimator risk

regime lag

jump sensitivity

sampling bias

DAILY WORKFLOW
  1. freeze path
  2. clean events
  3. compute estimators
  4. compare windows
  5. flag breaks
Production failure modes
  • unadjusted splits
  • mixed timezones
  • overnight gaps omitted
  • percent/decimal mismatch
09
MACRO CONNECTION

Map the transmission channel.

MACRO CONNECTION

Realized volatility as a regime recorder

Macro shocks enter the observed path through jumps, clustered returns and changing correlations; the window controls how long that regime remains visible.

Policy or growth shock

moves prices and correlations

Return path

records jumps and clustering

Estimator

weights and annualizes the path

Risk state

feeds limits and forecasts

10
COMMON PITFALLS

Most failures begin outside the formula.

01

Calling the estimate observable volatility.

02

Annualizing without stating the return interval.

03

Comparing OHLC and close-only estimators as if assumptions were identical.

04

Treating a rolling window as forward-looking.

11
SOURCES / FURTHER READING

Attribution with implementation authority.

researchBSD-3-Clause

Volatility, Monte Carlo and stochastic-volatility lectures

Research map for the mathematical progression and numerical experiments; prose, examples and code are original.

Source
Computational Finance Course
Author
L. A. Grzelak
Ref
main
OPEN ORIGINAL SOURCE ↗LICENSE ↗
implementation referenceQuantLib permissive license

Current volatility structures, processes, calibration helpers and tests

Implementation reference for production abstractions and validation patterns.

Source
QuantLib upstream
Author
QuantLib contributors
Ref
v1.42.1
OPEN ORIGINAL SOURCE ↗LICENSE ↗