# Yang-Zhang volatility estimator

Yang-Zhang volatility estimator is a measure of historical price variability that combines overnight opening gaps with intraday open-to-close and high-low movements.

## What it means

A stock can move while its exchange is closed and continue moving during the next trading session. The Yang-Zang estimator uses daily opening, high, low, and closing prices, plus the previous close, to capture both parts of that movement. It estimates **historical volatility**: the variability observed over a chosen sample, not the direction or size of the next move.

Its components separate overnight gaps, intraday open-to-close returns, and intraday high-low ranges. The result is expressed as a standard deviation of log returns per trading day when calculated from daily prices. Like other historical estimators, it depends on the observation window and the quality of the price data.

## How it is calculated

For `n` trading days, with `n > 2`, one common form is:

`σ_YZ² = σ_O² + kσ_C² + (1 − k)σ_RS²; k = 0.34 / [1.34 + (n + 1)/(n − 1)]`

- `O_i`, `H_i`, `L_i`, and `C_i` are day `i`’s open, high, low, and close prices, all in the same currency; `C_(i−1)` is the preceding trading day’s close.
- `o_i = ln(O_i / C_(i−1))` is the overnight log return. `σ_O²` is the **sample variance** of the `n` values of `o_i`.
- `c_i = ln(C_i / O_i)` is the intraday log return. `σ_C²` is the **sample variance** of the `n` values of `c_i`.
- `RS_i = ln(H_i / C_i) ln(H_i / O_i) + ln(L_i / C_i) ln(L_i / O_i)` is the Rogers-Satchell high-low variance term. `σ_RS²` is the average of the `n` values of `RS_i`, not their sample variance.
- `k` is a dimensionless weighting factor. `σ_YZ²` is daily log-return variance; `σ_YZ = √σ_YZ²` is daily volatility. Multiply `σ_YZ` by 100 to express it as a percentage.

All component returns are dimensionless. The sample variances use `n − 1` in their denominators, while the Rogers-Satchell average uses `n`.

## Worked example

The following component values are **hypothetical**, supplied to illustrate the final calculation rather than derived from a price series. Suppose a 21-trading-day sample gives overnight sample variance `σ_O² = 0.000100`, intraday sample variance `σ_C² = 0.000225`, and average Rogers-Satchell term `σ_RS² = 0.000196`.

1. Calculate the weight: `k = 0.34 / [1.34 + 22/20] ≈ 0.13934`.
2. Combine the components: `σ_YZ² = 0.000100 + 0.13934 × 0.000225 + 0.86066 × 0.000196 ≈ 0.000300`.
3. Take the square root: `σ_YZ ≈ √0.000300 ≈ 0.0173`, or **1.73% daily volatility**.

This is a variability estimate, not a statement that tomorrow’s return will be 1.73%.

## Why it matters before you trade

An overnight gap may be missed by a measure based only on close-to-close movements within a session or only on intraday ranges. Including both overnight and intraday information can make a pre-trade risk check more informative when a stock has meaningful opening gaps.

Volatility helps put a proposed position’s short-horizon price risk in context, but it is not the same as liquidity or execution cost. A volatility estimate also cannot specify a worst-case loss: unusual events can exceed what a historical sample suggests.

## How PreTrAIde uses it

PreTrAIde’s quantitative layer blends Yang-Zhang with Parkinson, close-to-close, and simplified GARCH(1,1) estimators to calculate daily volatility. That layer also calculates a 1-day 95% value at risk and 0–100 volatility scores for each stock and the basket. Pre-trade analysis returns a risk assessment and plain-language reasoning alongside its GO, NO-GO, or MODIFY verdict. Those verdicts are decision support, not trade recommendations.

## Common mistakes

- **Treating it as a forecast:** It summarizes historical movements; future volatility can differ.
- **Dropping the previous close:** The overnight return requires `C_(i−1)`, so `n` measured days need an earlier closing price.
- **Mixing methods or units:** The Rogers-Satchell term is averaged, not sample-varianced; variance must be square-rooted before reporting volatility as a percentage.
- **Ignoring price adjustments:** Splits or inconsistent price series can introduce artificial returns and distort the estimate.

---
Source: https://pretraide.com/glossary/yang-zhang-volatility
