Were markets exceptionally volatile in 2011?
Posted by The Average Investor on Jan 3, 2012
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:
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!

Gianpiero Ascenso said
I get this error message:
> djiVol <- aggregate(
+ Cl(DJI),
+ as.numeric(format(index(DJI), "%Y")),
+ function(ss) coredata(tail(TTR:::volatility(
+ ss,
+ n = NROW(ss),
+ calc = "close"), 1)))
Error in runCov(x, x, n, use = "all.obs", sample = sample, cumulative) :
Invalid 'n'
Since I'm a newbie, I don't know where to lojj for. Would you be so kind to point me in the right direction? Thanks
The Average Investor said
The code should work now. Apparently the new data from 2012 was breaking it.