# Were markets exceptionally volatile in 2011?

January 2, 2012
By

[This article was first published on The Average Investor's Blog » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

2011 was a volatile year, no doubt about that, but was it exceptionally so from a historic point of view? To quantify the volatility, I used the Dow Jones Industrial average, which goes back to 1928 on Yahoo Finance:

```library(quantmod)

getSymbols("^DJI", from="1900-01-01")

dji = Cl(DJI["/2011"])

djiVol = aggregate(
dji,
as.numeric(format(index(dji), "%Y")),
function(ss) coredata(tail(TTR:::volatility(
ss,
n=NROW(ss),
calc="close"), 1)))
ecdf(as.vector(djiVol))(as.numeric(tail(djiVol,1)))
# The result is 0.8214286, the 82nd quantile
```

A volatile year no doubt, but once again confirming the fact that, in markets behaviour at least, history does repeat itself. The following plot clearly shows that the volatility experienced during the great depression dwarves the recent levels:

Dow Jones Annual Volatility

Next, out of pure curiosity, I also computed how much money were to be made with these levels of volatility:

```library(quantmod)

getSymbols("^DJI", from="1900-01-01")

# Compute the absolute returns
absRets = abs(ROC(Cl(DJI["/2011"])))
absRets = reclass(ifelse(is.na(absRets),0,absRets),absRets)

# Summarize annually
yy = as.numeric(format(index(absRets), "%Y"))
zz = aggregate(absRets, yy, function(ss) tail(cumprod(1+ss),1))

print(as.vector(tail(zz,1)))
# The result is 10.64

```

That’s right, an owner of a crystal ball would have been able to multiply his money 10-fold in 2011 alone! For further comparison, in 1932, the owner of the same ball would have been able to multiply his money … 590 times!

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.