Measure Time Series Volatility Using Rogers-Satchell
How to Code Rogers-Satchell Volatility For Time Series Analysis
Rogers-Satchell volatility is a measure of volatility specifically designed for financial time series with an observed open, high, low, and close (OHLC) prices, which makes it particularly useful for asset returns that are not lognormally distributed.
This article presents this volatility measure in detail and shows how to code a rolling calculation on time series using Python.
Understanding Rogers-Satchell Volatility
Before discussing complex volatility models, it is always recommended to have a thorough understanding of the most basic volatility model (or calculation), that is the historical standard deviation. The standard deviation using the historical method is a common way to measure the volatility of a financial instrument based on past price data.
It quantifies the amount of variation or dispersion of a set of values. In finance, it typically measures the dispersion of daily returns around their mean. Follow these steps to calculate the standard deviation:
Calculate the returns using either the differencing (first function) or the log method (second function).
Calculate the average (mean) of the returns:
Compute the variance of the daily returns:
The standard deviation is the square root of the variance:
Like any statistical measure, it has its advantages and disadvantages. The historical standard deviation is straightforward to compute. It requires basic statistical operations that can be easily implemented in spreadsheets and programming languages. It is a well-understood measure of variability and is easy to explain to stakeholders who may not have a deep statistical background. Many financial models and risk metrics (such as the Sharpe ratio) rely on standard deviation as a measure of risk.
For small sample sizes, the historical standard deviation tends to underestimate true volatility. This bias can lead to misleading conclusions about the risk of an asset. The method assumes that the underlying volatility of the asset is constant over the period being analyzed. In reality, volatility can change over time, making this assumption unrealistic.
Additionally, financial returns often exhibit fat tails (leptokurtosis) and skewness, meaning they do not follow a normal distribution. The standard deviation does not capture these characteristics, potentially underestimating risk.
Use the following code in Python to calculate a rolling 5-day measure of volatility on Nvidia’s daily returns:
import numpy as np
import matplotlib.pyplot as plt
import yfinance as yf
def calculate_rolling_historical_volatility(data, window):
# Calculate returns (using the differencing method)
returns = data['Close'] - data['Close'].shift(1).dropna()
# Calculate the rolling standard deviation of the returns
rolling_volatility = returns.rolling(window=window).std()
# return a variable containing standard deviation measures
return rolling_volatility
# download the historical values of Nvidia
df = yf.download("NVDA", start = "2022-01-01", end = "2024-06-30")
# Define the rolling window size
window_size = 5
# apply the formula and get the volatility data frame
rolling_volatility = calculate_rolling_historical_volatility(df, window=window_size)
# plot volatility across time
plt.plot(rolling_volatility, color = 'black', label = '5-period historical standard deviation')
plt.legend()
plt.grid()
plt.axhline(y = np.mean(rolling_volatility), color = 'red', linestyle = 'dashed')
Rogers-Satchell volatility is a measure of volatility specifically designed for financial time series with an observed open, high, low, and close (OHLC) prices, which makes it particularly useful for asset returns that are not lognormally distributed.
This method was proposed by L.C.G. Rogers and S.E. Satchell in 1991. Unlike some other volatility measures, the Rogers-Satchell volatility does not assume zero mean returns, which can provide a more accurate reflection of market conditions.
The formula for Rogers-Satchell volatility is:
This method is particularly useful because it takes into account the intra-period volatility by using both the high and low prices, and does not rely on the assumption that the price returns are normally distributed. This makes it more flexible and potentially more accurate in various market conditions.
If you want to see more of my work, you can visit my website for the books catalogue by simply following this link:
Calculating Rogers-Satchell Volatility in Python
Let’s now use Python to calculate Rogers-Satchell volatility. We will use the same example (i.e. Nvidia’s daily returns with a lookback period of 5):
import numpy as np
import matplotlib.pyplot as plt
import yfinance as yf
import math
def rogers_satchell(price_data, window_size = 5, periods = 252, clean = True):
log_ho = (price_data["High"] / price_data["Open"]).apply(np.log)
log_lo = (price_data["Low"] / price_data["Open"]).apply(np.log)
log_co = (price_data["Close"] / price_data["Open"]).apply(np.log)
rs = log_ho * (log_ho - log_co) + log_lo * (log_lo - log_co)
def f(v):
return (periods * v.mean()) ** 0.5
result = rs.rolling(window = periods, center = False).apply(func=f)
if clean:
return result.dropna()
else:
return result
# download the historical values of Nvidia
df = yf.download("NVDA", start = "2020-01-01", end = "2024-06-30")
# Define the rolling window size
window_size = 5
# apply the formula and get the volatility data frame
rolling_volatility = rogers_satchell(df)
# plot volatility across time
plt.plot(rolling_volatility, color = 'black', label = '5-period Rogers-Satchell volatility')
plt.legend()
plt.grid()
plt.axhline(y = np.mean(rolling_volatility), color = 'red', linestyle = 'dashed')
The historical standard deviation is a useful and widely adopted measure of volatility due to its simplicity, ease of calculation, and general acceptance in the financial industry. However, its limitations, particularly in handling small sample sizes, non-stationary volatility, and the non-normal distribution of returns, suggest that it should be used with caution.
In situations where accuracy is paramount or sample sizes are small, alternative volatility models may provide better risk assessments.
You can also check out my other newsletter The Weekly Market Sentiment Report that sends weekly directional views every weekend to highlight the important trading opportunities using a mix between sentiment analysis (COT report, put-call ratio, etc.) and rules-based technical analysis.
If you liked this article, do not hesitate to like and comment, to further the discussion!