Calculating EWMA Volatility
Overview
One of the challenges of measuring volatility in finance is that the volatility is known to change over time.
This indicates that one cannot just do a
straight calculation of standard deviation.
In order to do the straight calculation, one must choose a sample size for doing the calculation. Typically this is done
by using a rolling window.
If the window size is chosen to be too small, the calculation is inaccurate and can oscillate between points.
If chosen to be too large, the volatility calculation on any given day may include points in the series where the volatility
was materially different that the point in question.
In addition to these issues, the calculation can suffer from wild oscillations when large price movements drop out the back
of the window.
One solution to these issues is to use the
exponentially weighted
algorithm applied to the volatility.
Calculating
The exponential weighted volatility is calculated as follows:
The value of the volatility for the first point is taken as the square of the return of the first data point.
{% \sigma_0^2 = R_0^2 %}
The volatility of the remaining points is calculated recursively.
{% \sigma_n^2 = \alpha \times R_n^2 + (1-\alpha) \times \sigma_{n-1}^2 %}
Here, {% \alpha %} is a parameter used to set the sensitivity of the volatility measure to the most recent points.