EWMA Volatility

Volatility is an important statistical factor for technical analysis. For example, we’ll require volatility for sharpe ratio, sortino ratio and etc.

Typically, we compute the volatility using the following formula:capture

When implementing this into a computer program, there will be practical consideration. For example, computing the variance for stocks of n days will require lots of computation among other computation that the program requires to do; and sometimes a price for a stock is missing then how will this formula be adjusted to the missing price?

By using exponential decay, one can calculate the volatility efficiently. The variance is using 1/n for each deviation factors, while the EWMA will use decay factors to control the average.

capture

Variance(t) = … + mu(t-3)^2*(1-lamda)*lamda^3 + mu(t-2)^2*(1-lamda)*lamda^2 + mu(t-1)^2*(1-lamda)*lamda^1 + mu(t)^2*(1-lamda)*lamda^0

using this expression, we can write the long term for sigma(t-1):

capture
Variance(t-1)= … + mu(t-4)^2*(1-lamda)*lamda^3+ mu(t-3)^2*(1-lamda)*lamda^2 + mu(t-2)^2*(1-lamda)*lamda^1 + mu(t-1)^2*(1-lamda)*lamda^0

substitute this term to the first equitation:

capture
Variance(t) = Variance(t-1)*lamda + mu(t)^2*(1-lamda)*lamda^0
=Variance(t-1)*lamda + mu(t)^2*(1-lamda)

If the variance is calculated daily, today’s variance can be computed using the previous day variance and today’s return.

Reference:
1. exponentially weighted moving average of volatility
http://www.investopedia.com/articles/07/ewma.asp

2. how to calculate historical volatility
http://www.investopedia.com/articles/06/historicalvolatility.asp

3. weighted moving average
https://en.wikipedia.org/wiki/Moving_average#Weighted_moving_average
https://en.wikipedia.org/wiki/Exponential_smoothing