Replication Package: Range-Based Volatility Estimators for Monitoring Market Stress

Read full text
Authors: Bo Pieter Johannes Andrée
Cited by: 0

Abstract

Replication Package: Range-Based Volatility Estimators for Monitoring Market Stress Paper: "Range-Based Volatility Estimators for Monitoring Market Stress: Evidence from Local Food Price Data" Author: Bo Pieter Johannes Andree, Data Group, World Bank Contact: bandree(at)worldbank.org Overview This repository contains the code and data needed to reproduce all figures and volatility calculations in the paper. The analysis computes six OHLC-based volatility estimators (close-to-close, Parkinson, Garman–Klass, Rogers–Satchell, Garman–Klass–Yang–Zhang, and Yang–Zhang) from monthly food price index data and plots them alongside documented event timelines for five country case studies. Repository Structure code_data/ ├── volatility_calculation.R Core volatility estimator functions ├── quantmod_TA_plot_extension.R Custom charting extension for quantmod ├── SDN_plot.R Sudan (Al Fashir) figures ├── SOM_plot.R Somalia (Baidoa) figures ├── CMR_plot.R Cameroon (Far North / Mara) figures ├── HTI_plot.R Haiti (Port-au-Prince) figures ├── PHL_plot.R Philippines (Sulu) figures ├── SDN_RTFP_mkt_2007_2025-11-24.csv Sudan price data ├── SOM_RTFP_mkt_2007_2025-11-24.csv Somalia price data ├── CMR_RTFP_mkt_2007_2025-11-24.csv Cameroon price data ├── HTI_RTFP_mkt_2007_2025-11-24.csv Haiti price data ├── PHL_RTFP_mkt_2007_2025-11-24.csv Philippines price data ├── *_plot.png / *_plot_all.png Pre-generated output figures ├── LICENSE MIT license └── readme.md / readme.html Documentation Data All price data are extracted from the World Bank Real-Time Food Prices (RTFP) system. Each CSV file contains monthly market-level OHLC food price indices and individual commodity prices for a single country. Source: World Bank Development Data Group, "Monthly food price estimates by product and market" (DOI: 10.48529/2ZH0-JF55). Methodology: The OHLC series are constructed using the methods described in Andree (2021, "Estimating Food Price Inflation from Partial Surveys," World Bank Policy Research Working Paper 9886) and Andree and Pape (2023, "Machine Learning Imputation of High Frequency Price Surveys in Papua New Guinea," World Bank Policy Research Working Paper 10559). CSV Column Descriptions Column Description ISO3 ISO 3166-1 alpha-3 country code country Country name adm1_name, adm2_name Administrative level 1 and 2 names mkt_name Market name lat, lon Market coordinates price_date Observation date (monthly, YYYY-MM-DD) o_food_price_index Open food price index h_food_price_index High food price index l_food_price_index Low food price index c_food_price_index Close food price index o_, h_, l_, c_ OHLC prices for individual commodities Updating Results Results can be updated with newer data by replacing the CSV files with a more recent extract from the World Bank RTFP data portal. The scripts select specific markets by name (e.g., plot_mkt = "Al Fashir"), so the replacement file must contain the same market and column structure. Requirements R (>= 4.0) with packages quantmod, TTR, and xts. install.packages(c("quantmod", "TTR", "xts")) Reproducing the Figures Set your R working directory to the folder containing these files. Source the core functions: source("volatility_calculation.R") source("quantmod_TA_plot_extension.R") Run any country script to regenerate its figures: source("SDN_plot.R") # Sudan source("SOM_plot.R") # Somalia source("CMR_plot.R") # Cameroon source("HTI_plot.R") # Haiti source("PHL_plot.R") # Philippines Each script produces two PNG files in the working directory: File Content _plot_all.png Candlestick chart with all six volatility estimators _plot.png Technical detection chart with RSI, Yang–Zhang volatility, and event annotations Volatility Estimators This section documents the six volatility estimators implemented in volatility_calculation.R. The methods apply to any OHLC price series. Setup and Notation We observe prices at equally spaced times $t = 0, 1, 2, \ldots$. For each observation period $t$ we denote: Symbol Meaning $O_t$ Opening price $H_t$ Highest price during the period $L_t$ Lowest price during the period $C_t$ Closing price We work with natural logarithms of price ratios. For brevity, define: Quantity Definition Log range $d_t = \ln(H_t / L_t)$ Log open–close return $c_t = \ln(C_t / O_t)$ "Overnight" log return $o_t = \ln(O_t / C_{t-1})$ As a continuous-time benchmark we assume the efficient price follows a geometric Brownian motion, $$dP_t = \mu P_t \, dt + \sigma P_t \, dW_t,$$ so that log prices satisfy $$d\ln P_t = \left(\mu - \tfrac{1}{2}\sigma^2\right)dt + \sigma \, dW_t.$$ Let $\Delta t$ be the length of one observation period in years (e.g. $\Delta t = 1/252$ for daily data, $\Delta t = 1/12$ for monthly data). Then $\sigma^2 \Delta t$ is the per-period variance parameter. All estimators are computed over rolling windows of length $n$ periods. For a generic per-period variance estimator $\hat{v}_t$, the annualized volatility is $$\hat{\sigma}_t = \sqrt{N \,\hat{v}_t}.$$ 1. Close-to-Close Volatility The close-to-close estimator uses only closing prices and treats the returns as arithmetic rates of change, $$r_t = \frac{C_t - C_{t-1}}{C_{t-1}}.$$ Given a window of $m$ returns $\{r_i\}_{i=t-m+1}^{t}$, the sample variance is $$\widehat{\operatorname{Var}}(r)_t = \frac{1}{m-1} \sum_{i=t-m+1}^{t} \bigl(r_i - \bar{r}_t\bigr)^2, \qquad \bar{r}_t = \frac{1}{m} \sum_{i=t-m+1}^{t} r_i.$$ The annualized close-to-close volatility is then $$\hat{\sigma}_{\mathrm{CC},t} = \sqrt{N \,\widehat{\operatorname{Var}}(r)_t}.$$ In the implementation we use $m = n-1$ returns corresponding to $n$ prices. As an alternative, when mean returns are assumed negligible, one can estimate the per-period variance via squared returns, $$\hat{v}_{\mathrm{CC},0,t} = \frac{1}{m'} \sum_{i=t-m'+1}^{t} r_i^2,$$ and set $\hat{\sigma}_{\mathrm{CC},0,t} = \sqrt{N \,\hat{v}_{\mathrm{CC},0,t}}$. 2. Parkinson High–Low Estimator Parkinson's (1980) estimator uses only the high and low within each period. Under the geometric Brownian motion model with zero drift and continuous trading, the log range satisfies $$\mathbb{E}\bigl[d_t^2\bigr] = 4 \ln 2 \,\sigma^2 \Delta t.$$ A method-of-moments estimator of the per-period variance based on this identity is $$\hat{v}_{P,t} = \frac{1}{4 n \ln 2} \sum_{i=t-n+1}^{t} d_i^2,$$ and the corresponding annualized Parkinson volatility is $$\hat{\sigma}_{P,t} = \sqrt{N \,\hat{v}_{P,t}}.$$ This estimator is substantially more efficient than close-to-close when the zero-drift, continuous-trading assumptions are reasonable, but it can become biased in strongly trending markets. 3. Garman–Klass Estimator Garman and Klass (1980) derive an estimator that uses both the range and the open–close return. Their per-period variance estimator is $$\hat{v}_{GK,t} = \frac{1}{n} \sum_{i=t-n+1}^{t} \left(\frac{1}{2} d_i^2 - (2\ln 2 - 1)\, c_i^2 \right).$$ Under geometric Brownian motion with zero drift, this is an unbiased estimator of $\sigma^2 \Delta t$ and is more efficient than both close-to-close and Parkinson. The annualized volatility is $$\hat{\sigma}_{GK,t} = \sqrt{N \,\hat{v}_{GK,t}}.$$ 4. Rogers–Satchell Estimator Rogers and Satchell (1991) propose an estimator that remains unbiased for variance even in the presence of non-zero drift. One convenient equivalent form of the Rogers–Satchell contribution for period $t$ is $$q_t = \ln\!\left(\frac{H_t}{C_t}\right)\ln\!\left(\frac{H_t}{O_t}\right) + \ln\!\left(\frac{L_t}{C_t}\right)\ln\!\left(\frac{L_t}{O_t}\right).$$ The per-period variance estimator over a window is $$\hat{v}_{RS,t} = \frac{1}{n} \sum_{i=t-n+1}^{t} q_i,$$ and the annualized Rogers–Satchell volatility is $\hat{\sigma}_{RS,t} = \sqrt{N \,\hat{v}_{RS,t}}$. Under geometric Brownian motion with arbitrary constant drift $\mu$, this estimator is unbiased for $\sigma^2 \Delta t$, making it more robust than Garman–Klass when there are strong trends. 5. Garman–Klass–Yang–Zhang Extension The GK–YZ extension (Yang & Zhang, 2000) augments the Garman–Klass estimator by incorporating squared close-to-open jumps between periods. The per-period variance estimator over a window is $$\hat{v}_{GKYZ,t} = \frac{1}{n} \sum_{i=t-n+1}^{t} \left[ o_i^2 + \frac{1}{2} d_i^2 - (2\ln 2 - 1)\, c_i^2 \right],$$ with annualized volatility $\hat{\sigma}_{GKYZ,t} = \sqrt{N \,\hat{v}_{GKYZ,t}}$. When between-period jumps are important, this estimator captures both those jumps and within-period variation. 6. Yang–Zhang Estimator Yang and Zhang (2000) propose a volatility estimator that combines three components: (i) the variance of close-to-open returns $o_t$, (ii) the variance of open-to-close returns $c_t$, and (iii) the intraday Rogers–Satchell variance. The close-to-open and open-to-close components are computed as sample variances over the last $n$ periods: $$\hat{v}_{o,t} = \widehat{\operatorname{Var}}(o_i)_{i=t-n+1}^{t}, \qquad \hat{v}_{c,t} = \widehat{\operatorname{Var}}(c_i)_{i=t-n+1}^{t}.$$ The Yang–Zhang per-period variance estimator is a weighted sum, $$\hat{v}_{YZ,t} = \hat{v}_{o,t} + k \,\hat{v}_{c,t} + (1-k)\,\hat{v}_{RS,t},$$ with weight $k \in (0,1)$ chosen as $$k = \frac{\alpha - 1}{\alpha + \frac{n+1}{n-1}},$$ where $\alpha$ is typically taken as $\alpha \approx 1.34$. For large $n$, $k \longrightarrow (\alpha-1)/(\alpha+1)$. The annualized Yang–Zhang volatility is $$\hat{\sigma}_{YZ,t} = \sqrt{N \,\hat{v}_{YZ,t}}.$$ The Yang–Zhang estimator is drift-independent (through the Rogers–Satchell component) and incorporates between-period jumps efficiently. In empirical applications it typically exhibits lower varian

Fields of Study & Subjects

Financial Risk and Volatility Modeling Market Dynamics and Volatility Economics of Agriculture and Food Markets

Publication details

Journal / source
arXiv (Cornell University)
Publication date
3 March 2026
Language
EN
Document type
Preprint