Realized Volatility Estimators in Python: Close-to-Close vs Parkinson, Garman-Klass, Rogers-Satchell, Yang-Zhang

Every volatility model — from a Bollinger band to a full GARCH stack — starts with the same question: how do you measure how much an asset actually moves? If you build trading signals, risk models, or ML features on volatility, the estimator you pick matters as much as the window you pick. The default answer, close-to-close realized volatility, throws away three of the four numbers in every OHLC bar. Range-based estimators — Parkinson, Garman-Klass, Rogers-Satchell, Yang-Zhang — use the high, low, and open to extract more information per bar, and in our simulation they cut the RMSE of the volatility estimate by 50–62% at 10- and 21-day windows. Each carries structural assumptions, especially around overnight gaps, that determine which one a quant should actually deploy.
Figures come from a simulation we ran; formulas are taken from a FlashAlpha write-up, with Parkinson (1980) cited for the high-low estimator. We did not backtest on live market data.
Why close-to-close volatility wastes data
A daily OHLC bar contains four numbers: open, high, low, close. Close-to-close volatility uses exactly one of them — the close — and ignores how far the price traveled intraday and where the bar opened. Under a random walk, the high-low range is a far tighter proxy for true variance than a single squared log return, because the range accumulates information from every tick inside the bar, not just the endpoints. That is the entire motivation for range-based estimators: more information per bar means a lower-variance estimate of the same underlying quantity. The price of that efficiency is a set of assumptions — about drift, about the open, about gaps — that close-to-close never has to make. The rest of this post makes those assumptions explicit, implements all five estimators in pandas, and quantifies the efficiency gain with a controlled simulation.
The five estimators, formula by formula
All formulas below are annualised with 252 trading days and use n bars per window. We cite the Parkinson estimator to the Parkinson (1980) paper; its full text is paywalled and we did not read it, so the formulas for all five estimators are taken from the FlashAlpha write-up.
Close-to-close. σ²_CC = 252/(n−1) · Σ (ln(C_t/C_{t−1}) − mean)². The benchmark. One squared log return per bar; unbiased under GBM in our simulation; the noisiest estimate in the family.
Parkinson. σ²_P = 252/(4n·ln2) · Σ (ln(H_t/L_t))². Uses only the high-low range. Ignores overnight gaps and is biased low under discrete sampling.
Garman-Klass. σ²_GK = 252/n · Σ [0.5·(ln(H/L))² − (2·ln2 − 1)·(ln(C/O))²]. Adds an open-to-close term, ln(C/O), that only partially accounts for gaps. Assumes open = previous close — reasonable in continuous or near-continuous markets, wrong on gapped equities.
Rogers-Satchell. σ²_RS = 252/n · Σ [ln(H/C)·ln(H/O) + ln(L/C)·ln(L/O)]. Designed to handle nonzero drift; the FlashAlpha comparison marks Parkinson and Garman-Klass as not handling drift. No overnight term.
Yang-Zhang. σ²_YZ = σ²_o + k·σ²_c + (1−k)·σ²_RS, where σ²_o is the variance of overnight ln(O_t/C_{t−1}), σ²_c the variance of ln(C_t/O_t), and k = 0.34/(1.34 + (n+1)/(n−1)). k is a weighting constant: it is about 0.14 at n = 21 and tends to 0.145 as n grows. The Rogers-Satchell term gets weight 1−k against k for the open-to-close term. This is the only estimator here that models overnight gaps explicitly.
Python implementations on a pandas OHLC DataFrame
Each function below takes a DataFrame with lowercase open, high, low, close columns and returns an annualised rolling vol series over a window n. The annualisation constant is 252 trading days: every variance formula multiplies by 252, and the square root is taken at the end. The Yang-Zhang function computes the same per-bar Rogers-Satchell term inline, averaged over the window rather than summed. All five functions are pure pandas/numpy — no external vol libraries — so they drop straight into a feature pipeline or a backtest loop.
import numpy as np, pandas as pd
def close_to_close(df, n=21):
r = np.log(df["close"] / df["close"].shift(1))
return np.sqrt(252 * r.rolling(n).var(ddof=1))
def parkinson(df, n=21):
hl = np.log(df["high"] / df["low"])
return np.sqrt(252 * (hl ** 2).rolling(n).sum() / (4 * n * np.log(2)))
def garman_klass(df, n=21):
hl = np.log(df["high"] / df["low"]); co = np.log(df["close"] / df["open"])
v = 0.5 * hl**2 - (2*np.log(2) - 1) * co**2
return np.sqrt(252 * v.rolling(n).sum() / n)
def rogers_satchell(df, n=21):
lhc = np.log(df["high"] / df["close"]); lho = np.log(df["high"] / df["open"])
llc = np.log(df["low"] / df["close"]); llo = np.log(df["low"] / df["open"])
return np.sqrt(252 * (lhc * lho + llc * llo).rolling(n).sum() / n)
def yang_zhang(df, n=21):
k = 0.34 / (1.34 + (n + 1) / (n - 1))
o_var = np.log(df["open"] / df["close"].shift(1)).rolling(n).var(ddof=1)
c_var = np.log(df["close"] / df["open"]).rolling(n).var(ddof=1)
rs = (np.log(df["high"] / df["close"]) * np.log(df["high"] / df["open"])
+ np.log(df["low"] / df["close"]) * np.log(df["low"] / df["open"])).rolling(n).mean()
return np.sqrt(252 * (o_var + k * c_var + (1 - k) * rs))
Usage on a synthetic 60-day sample built from 390 one-minute bars per day. The days are chained, so each overnight gap is a single bar’s move, effectively zero:
rng = np.random.default_rng(42)
minute = rng.normal(0, 0.30 / np.sqrt(252 * 390), 60 * 390).cumsum().reshape(60, 390)
px = 100 * np.exp(minute)
df = pd.DataFrame({"open": px[:, 0], "high": px.max(axis=1),
"low": px.min(axis=1), "close": px[:, -1]})
for f in (close_to_close, parkinson, garman_klass, rogers_satchell, yang_zhang):
print(f.__name__, round(f(df, n=21).iloc[-1], 4))
Each function returns a pandas Series aligned to the input index. Parkinson, Garman-Klass and Rogers-Satchell have n−1 leading NaNs; close-to-close and Yang-Zhang have n, because they use a lagged close.
Simulation results: how much efficiency do you actually gain?
We ran our own simulation (sim_estimators.py): 2,000 trials of geometric Brownian motion with zero drift, true annual sigma 0.30, 390 one-minute steps per day, and no overnight gap. For each trial we computed all five estimators at 10- and 21-day windows and scored them against the true 0.30.
| Estimator | 10d vol (√ mean variance) | 10d RMSE | 10d RMSE ratio | 21d vol (√ mean variance) | 21d RMSE | 21d RMSE ratio |
|---|---|---|---|---|---|---|
| Close-to-close | 0.3035 | 0.0754 | 1.00 | 0.3007 | 0.0487 | 1.00 |
| Parkinson | 0.2915 | 0.0323 | 0.428 | 0.2905 | 0.0230 | 0.474 |
| Garman-Klass | 0.2870 | 0.0284 | 0.377 | 0.2865 | 0.0221 | 0.453 |
| Rogers-Satchell | 0.2871 | 0.0314 | 0.416 | 0.2864 | 0.0240 | 0.493 |
| Yang-Zhang | 0.2894 | 0.0295 | 0.391 | 0.2885 | 0.0214 | 0.441 |
The RMSE ratio column is the headline. At 10 days, Parkinson’s error is 0.428× close-to-close’s, Garman-Klass 0.377×, Rogers-Satchell 0.416×, Yang-Zhang 0.391×. Squaring those ratios gives a rough variance-efficiency multiplier: about 5.5× for Parkinson and 7× for Garman-Klass at 10 days. These are consistent with the secondary figures FlashAlpha reports (~5× and ~7–8×), but our simulation is not independent proof of them. At 21 days the ordering shifts: Yang-Zhang (0.441×) edges Garman-Klass (0.453×). Garman-Klass leads at 10 days, and the two are close in a gap-free simulation.
The vol columns show every range estimator landing between 0.286 and 0.292 against the true 0.30 — a downward bias of roughly 3–4.5% at both windows, consistent with discrete sampling of a continuous path. Close-to-close is essentially unbiased (0.3035 at 10 days, 0.3007 at 21 days).
Yang-Zhang does not show its signature advantage here, and that is expected: the simulation contains no overnight gaps, so the overnight-variance term it adds has nothing to capture. We do not claim this simulation proves or disproves Yang-Zhang’s overnight-handling benefit — it is simply unmeasured in this setup.
Which estimator when: a decision guide
- Close-to-close — the benchmark. Assumption-free under GBM, but the noisiest estimate. Keep it in every comparison as the reference point.
- Parkinson — the quick option. Needs only high and low. Strong efficiency per unit of information, but biased low and blind to gaps.
- Garman-Klass — the efficiency leader at 10 days in our sim; Yang-Zhang edges ahead at 21 days. Its assumption, open equals previous close, holds in continuous markets and breaks on gapped equities.
- Rogers-Satchell — the drift-aware choice. The FlashAlpha comparison marks Parkinson and Garman-Klass as not handling drift. No overnight term.
- Yang-Zhang — the overnight-aware option. It is the natural default when gaps matter — earnings, macro events, weekend risk — but our gap-free simulation cannot demonstrate that benefit. Treat it as the theoretically motivated upgrade and validate it on your own data.
Caveats and limitations
- No overnight gaps in the simulation. Yang-Zhang’s overnight-handling advantage is not measured here. Do not read the table as evidence for or against it.
- Range estimators are biased low by roughly 3–4.5% in this sim (0.286–0.292 vs the true 0.30) at both windows.
- The simulation assumes GBM, zero drift, no microstructure noise, and no fat tails. Real equity data — earnings gaps, jumps, autocorrelated order flow — can change the ranking. Treat the numbers as directional, not definitive.
- Garman-Klass assumes open = previous close; Rogers-Satchell has no overnight term. Each carries its own assumption.
- No live market price data was used. Every figure above traces to the simulation, not to market data.
FAQ
Why is Parkinson volatility biased low?
It uses only the high-low range, and a discretely sampled bar rarely captures the continuous path’s true extremes. In our GBM simulation, Parkinson and the other range estimators came in roughly 3–4.5% below the true 0.30 annual vol at both windows. Discrete sampling is the usual explanation; we did not test it separately.
Does Yang-Zhang beat Garman-Klass?
It depends on the window in our simulation. Yang-Zhang edges Garman-Klass at 21 days (RMSE 0.0214 vs 0.0221) but trails at 10 days (0.0295 vs 0.0284). Yang-Zhang should pull ahead when overnight moves are material, such as stocks with earnings gaps, but our gap-free sim does not test that.
Which estimator should I use for production?
Start with Rogers-Satchell if drift is a concern, Garman-Klass if open roughly equals the previous close, and Yang-Zhang if overnight gaps matter. Keep close-to-close as a benchmark. Validate on your actual data — our results are simulation-only.
← Back to all posts

