Nov 16

Exponentially Weighted Moving Average (EWMA)

by David Harper, CFA, FRM, CIPM


FRM | Quant | |

Volatility is the most common measure of risk. But there are several flavours of volatility. In a previous tutorial, we showed how to calculate simple historical volatility. We computed Google’s actual stock volatility based on 30 days of price data. Now we will improve on simple volatility. But first, let’s put this metric into a bit of perspective. There are two broad approaches: historical and implied (or implicit). The historical approach assumes that past is prologue; we measure history in the hopes it is predictive. Implied volatility, on the other hand, ignores history; it solves for the volatility implied by market prices. It hopes that the market knows best and that market prices contain, even if implicitly, consensus estimates of volatility.

volatilityFlavors

If we focus on just the three historical approaches (above left), they have in common two steps:

  1. Calculate the series of periodic returns, and
  2. Apply a weighting scheme

First, we calculate the periodic returns. That’s typically a series of daily returns where each return is expressed in continually compounded terms. For each day, we take the natural log of the ratio of stock prices (i.e., today’s price divided by yesterday’s, and so on):

PeriodReturn

This produces a series of daily returns, from ui to ui-m, depending on how many days (m = days) we measure.

Simple variance assigns equal weight to each (squared) return

That gets us to the second step, weighting the series of periodic returns. This is where the three historical approaches differ. In the previous tutorial, we showed that, under a couple of acceptable simplifications, the simple variance is “simply” the average of the squared returns:

SimpleVariance

Notice that this simply sums each of the periodic returns, then divides that total by the number of days or observations (m). So, it’s really just an average of the squared, periodic returns. Put another way, each squared return is given an equal weight. So if alpha (a) is a weighting factor (specifically, a = 1/m) then a simple variance looks something like this:

simpleWeight

The weakness of this approach is that all returns earn the same weight. Yesterday’s (very recent) return has no more influence on the variance than last month’s return.

EWMA assigns greater weight to more recent (squared) returns

This is the problem fixed by the exponentially weighted moving average (EWMA): more recent returns have greater weight on the variance. The exponentially weighted moving average (EWMA) introduces lambda, called the smoothing parameter. Lambda must be less than one. Under that condition, instead of equal weights, each squared return is weighted by a multiplier as follows:

EwmaWeight

For example, RiskMetricsTM tends to use a lambda of 0.94 or 94%. In that case, the first (most recent) squared periodic return is weighted by (1-0.94)(.94)0 = 6%. The next squared return is simply a lambda-multiple of the prior weight; in this case, 6% multiplied by 94% = 5.64%. And the third prior day’s weight equals (1-0.94)(0.94)2= 5.30%.

That’s the meaning of “exponential” in EWMA: each weight is a constant multiplier (i.e., lambda, which must be less than one) of the prior day’s weight. This ensures a variance that is weighted or biased toward more recent data. If you would like to view the actual worksheet for Google’s volatility (file here), see the final three columns (column O, P, and Q) for the difference between simple volatility and EWMA.

xls_ewma

Simple volatility effectively weighs each and every periodic return by 0.196% as shown in the first column (column O; we had two years of daily stock price data. That is 509 daily returns and 1/509 = 0.196%). But notice the next column (column P) assigns a weight of 6%, then 5.64%, then 5.3% and so on. That’s the only difference between simple variance and EWMA. Don’t forget: after we sum the entire series (in column Q) we have the variance, which is the square of the standard deviation. If we want volatility, we need to remember to take the square root of that variance.

What’s the difference in Google’s case? It’s significant.The simple variance gave us a daily volatility of 2.4% but the EWMA gave a daily volatility of only 1.4% (see the spreadsheet for details). Apparently, Google’s volatility settled down more recently. A simple variance might be artificially high.

The EWMA series reduces to a recursive formula

You’ll notice we needed to compute a long series of exponentially declining weights. We won’t do the math here, but one of the best features of the EWMA is that the entire series conveniently reduces to a recursive formula:

Ewma

Recursive means that today’s variance references (i.e., is a function of the prior day’s variance). You can find this formula in the spreadsheet also, and it produces the exact same result as the longhand calculation! It says: today’s variance (under EWMA) equals yesterday’s variance(weighted by lambda) plus yesterday’s squared return (weighed by one minus lambda). Notice how it just adds two terms together: yesterday’s weighted variance and yesterday’s weighted, squared return.

But still, lambda is our smoothing parameter. A higher lambda (e.g., like RiskMetric’s 94%) indicates slower decay in the series--in relative terms, we are going to have more data points in the series and they are going to “fall off” more slowly. On the other hand, if we reduce the lambda, we indicate higher decay: the weights fall off more quickly and, as a direct result of the rapid decay, fewer data points are used. (in the spreadsheet,lambda is an input, so you can experiment with its sensitivity).

Summary

Volatility is the instantaneous standard deviation of a stock and the most common risk metric. It is also the square root of variance. We can measure variance at least three ways historically or implicitly (implied volatility). Historically, the easiest method is simple variance. But the weakness with simple variance is all returns get the same weight. So we face a classic trade-off: we always want more data but the more data we have the more our calculation is diluted by distant (less relevant) data. The exponentially weighted moving average (EWMA) improves on simple variance by assigning weights to the periodic returns. By doing this, we can both use a large sample size but also give greater weight to more recent returns.


Comments

  1. The video presentation of this article states that users can download the check the spreadsheet discussed in the article to understand better as to what has been done in the exercise. I was unable to trace a link to download the spreadsheet. Was the link initially available and then removed or was it a mistake that it was never made available for users to download?

    The article as such was very good and clear, but also failed to indicate as to how this is piece of Exponentially Weighted Moving Average is used. Calculating the EWMA is clear, but when and where is it used? Is it the topic for the next article?

  2. very good article.
    Cannot wait to see an thorough explaination of
    GARCH(x,y) with practical examples

  3. Hello David. Great article. By any chance that you can make the spread sheet available for download?

  4. Hi David , great concept
    How to calculate volatility on spreadsheet using GARCH.

Leave a Comment