Powered by OpenAIRE graph
Found an issue? Give us feedback
addClaim

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

Authors: Andree, Bo Pieter Johannes;

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

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 variance than the simpler historical and range-based estimators. Annualization and Rolling Windows All estimators follow the same pattern: (1) a per-period variance $\hat{v}_t$ is estimated from the OHLC data over a window $\{t-n+1,\ldots,t\}$; (2) the variance is annualized by multiplying by $N$ (e.g. $N=12$ for monthly, $N=52$ for weekly, $N=252$ for trading days); (3) the annualized volatility is $\hat{\sigma}_t = \sqrt{N\,\hat{v}_t}$. The choice of $n$ governs the smoothness–responsiveness trade-off: larger $n$ yields more stable but slower-reacting estimates; smaller $n$ is more responsive but noisier. Summary Table Estimator calc argument Key property Close-to-close "close" Uses only closing prices Parkinson "parkinson" Uses high–low range; efficient under zero drift Garman–Klass "garman.klass" Uses range and open–close; efficient under zero drift Rogers–Satchell "rogers.satchell" Drift-independent GK–Yang–Zhang "gk.yz" Garman–Klass extended with overnight jumps Yang–Zhang "yang.zhang" Drift-independent; combines overnight, open–close, and Rogers–Satchell All estimators return annualized volatility computed over a rolling window (default: $n = 10$, $N = 12$ for monthly data). Application to Food Prices The volatility metrics are applied to the Open, High, Low, Close prices of the Real-Time Food Prices data to assess whether volatility jumps detect major shocks. Several country scripts are provided. Below, the Sudan (Al Fashir) case study illustrates the approach. Example: Volatility–Event Timeline for Al Fashir Food Prices Figure 1 (SDN_plot_all.png): Log food prices (index) in Al Fashir, Sudan, together with the six volatility metrics. The different approaches are roughly aligned but have slightly different sensitivity to jumps and to periods where there is relatively higher within-period volatility. Figure 2 (SDN_plot.png): Technical setup to detect volatility shocks. Top panel: log food prices in Al Fashir. Middle panel: standard RSI with 30 and 70 levels. Bottom panel: Yang–Zhang volatility estimator. The blue line indicates the 12-month moving average. Red lines indicate where volatility is above the 12-month moving average or above the 90th percentile. Volatility Episodes and Conflict–Macro Shocks in Al Fashir, Sudan The volatility series picks up several distinct episodes that align closely with major macroeconomic and conflict events in Sudan and, more specifically, in Darfur. 1. 2007–2009 — Global food price crisis and ongoing Darfur war. The first large volatility hump coincides with the 2007–2008 global food price crisis, when international cereal prices doubled and import bills for low-income countries surged. At the same time, Darfur remained an active war zone, with displacement, banditry and disrupted trade routes into Al Fashir. These global and local shocks jointly raise both the level and variability of local food prices. 2. 2010 — Election period and fragile security in Darfur. A smaller but visible volatility uptick appears around the April 2010 general elections, which returned President Bashir to office amid boycotts and continued violence in Darfur. Insecurity and shifting control of trade corridors likely made local market conditions more fragile. 3. 2011–2014 — South Sudan secession, austerity measures and protest waves. The second major volatility hump spans roughly 2012–2014. After South Sudan's independence in 2011, Sudan lost most of its oil revenue, triggering a sharp deterioration in its terms of trade, currency depreciation and rising inflation. The government responded with austerity and fuel-subsidy cuts in 2012 and 2013, which in turn sparked large protest waves and deadly repression. This combination of macro adjustment, subsidy removal and political unrest is reflected in elevated, choppy volatility of local food prices. 4. 2016 — Jebel Marra offensive and renewed violence in Darfur. Around 2016, volatility rises again, aligning with a major government offensive in Jebel Marra and widespread attacks on civilians in Darfur documented by Amnesty International. These operations disrupted rural livelihoods and movements, likely affecting grain inflows into Al Fashir. 5. 2017–2019 — Deepening economic crisis, bread-price protests and the 2018–2019 revolution. A pronounced hump in 2017–2019 corresponds to Sudan's deepening macroeconomic crisis—rapid currency depreciation, inflation above 70 percent, and shortages of bread and fuel—culminating in nationwide bread-price protests from December 2018 and the mass mobilization that toppled Bashir in April 2019. The volatility spike captures this transition from chronic high inflation to an acute episode of politically driven price surges and supply disruptions. 6. 2019–2022 — Transitional reforms, hyperinflation and the October 2021 coup. After 2019, volatility does not return to earlier lows. The civilian–military transitional government implemented exchange-rate and subsidy reforms under severe macro stress, contributing to high and unstable prices. The October 25, 2021 military coup dissolved power-sharing institutions and derailed the transition, adding another layer of political uncertainty. The volatility measure shows a persistent, elevated plateau during this period. 7. 2022–mid-2023 — Post-coup stagnation and mounting food-security stress. From 2022, volatility trends upward even before the outbreak of full-scale war. FEWS NET reporting documents continued very high inflation, worsening terms of trade and severe food-security outcomes in Darfur and other regions during this post-coup period. 8. mid-2023–2025 — SAF–RSF war, siege of El Fasher and famine conditions. The largest and most persistent volatility spike occurs from mid-2023 onward. In April 2023, open war broke out between the Sudanese Armed Forces (SAF) and the Rapid Support Forces (RSF), producing massive displacement and destruction of infrastructure nationwide and particularly in Darfur. El Fasher became the focus of an extended RSF siege lasting well over a year, with repeated attacks and systematic obstruction of aid access. By late 2025, the IPC classified El Fasher and other areas as facing famine (Phase 5), driven by siege, trade blockade, and collapse of purchasing power. In the Al Fashir market data, this period is characterized by extreme, sustained volatility, reflecting intermittent supplies, sharp price jumps and corrections, and the overall breakdown of normal market functioning. Taken together, these episodes illustrate that the volatility measure is not only reacting to generic macro instability but is tightly aligned with specific conflict events, policy shifts and siege dynamics that affect local food availability and price formation in Al Fashir. The metric captures both "global" shocks (such as the 2007–2008 food-price crisis) and highly localized war-related disruptions, making it a useful proxy for market stress in conflict-affected settings. Citation Andree, B. P. J. (2026). Range-Based Volatility Estimators for Monitoring Market Stress: Evidence from Local Food Price Data. Working Paper. License This project is licensed under the MIT License. See the LICENSE file for details. References Amnesty International. (2014, September 3). Sudan: Those behind unlawful killings and torture of protesters must be brought to justice. Amnesty International. Amnesty International. (2016). Scorched earth, poisoned air: Sudanese government forces ravage Jebel Marra, Darfur. Amnesty International. Famine Early Warning Systems Network. (2024). Sudan: Food security outlook. FEWS NET. Food and Agriculture Organization of the United Nations. (2009). The food price crisis of 2007/2008: Evidence and implications for food security. FAO. Freedom House. (2022). The case of the 2018–2019 revolution in Sudan. In Civic mobilizations in authoritarian contexts (Special report). Freedom House. Garman, M. B., & Klass, M. J. (1980). On the estimation of security price volatilities from historical data. Journal of Business, 53(1), 67–78. doi:10.1086/296072 Human Rights Watch. (2013, September 27). Sudan: Dozens killed during protests. Human Rights Watch. Lewis, A. (2023, July 13). Sudan conflict: What's behind the war? Reuters. Link Parkinson, M. (1980). The extreme value method for estimating the variance of the rate of return. Journal of Business, 53(1), 61–65. doi:10.1086/296071 Rogers, L. C. G., & Satchell, S. E. (1991). Estimating variance from high, low and closing prices. The Annals of Applied Probability, 1(4), 504–512. doi:10.1214/aoap/1177005835 Schneid, R. (2025, October 7). Famine spreads to two more areas in Sudan, including city subject to militia atrocities. Time. Link Townsend, M. (2025, September 24). 'We will never, ever escape': Inside the ever-tightening siege of the Sudanese city of El Fasher. The Guardian. World Bank. (2024). Sudan: Overview. World Bank. Yang, D., & Zhang, Q. (2000). Drift-independent volatility estimation based on high, low, open, and close prices. Journal of Business, 73(3), 477–492. doi:10.1086/209650 The Guardian. (2012, June 21). Sudan austerity announcement sparks widespread protests.

Keywords

range-based estimators, volatility estimation, OHLC data, price monitoring, market stress, food prices

  • BIP!
    Impact byBIP!
    selected citations
    These citations are derived from selected sources.
    This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
    0
    popularity
    This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network.
    Average
    influence
    This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
    Average
    impulse
    This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network.
    Average
Powered by OpenAIRE graph
Found an issue? Give us feedback
selected citations
These citations are derived from selected sources.
This is an alternative to the "Influence" indicator, which also reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
BIP!Citations provided by BIP!
popularity
This indicator reflects the "current" impact/attention (the "hype") of an article in the research community at large, based on the underlying citation network.
BIP!Popularity provided by BIP!
influence
This indicator reflects the overall/total impact of an article in the research community at large, based on the underlying citation network (diachronically).
BIP!Influence provided by BIP!
impulse
This indicator reflects the initial momentum of an article directly after its publication, based on the underlying citation network.
BIP!Impulse provided by BIP!
0
Average
Average
Average