2018 Volatility Recap

[This article was first published on R – Quintuitive, 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.

2018 brought more volatility to the markets, which so far has spilled into 2019. Let’s take a look at the long term volatility history picture using the Dow Jones Industrial Average:

Indeed, 2018 was the most volatile year since 2011. Relatively speaking however, the volatility is on the low end for a bear market, which I believe started in late December.

The above chart was produced using the following R code:


dji.annual.volatility = function(dji, year) {
   dates = paste("/", as.character(year), sep="")
   dji = na.exclude(dji[dates])
   djiVol = aggregate(dji, as.numeric(format(index(dji), "%Y")),
               function(ss) coredata(tail(TTR:::volatility(
               calc="close"), 1)))
   xx = ecdf(as.vector(djiVol))(as.numeric(tail(djiVol,1)))
   absRets = na.exclude(abs(ROC(dji[dates], type="discrete")))
   yy = as.numeric(format(index(absRets), "%Y"))
   zz = aggregate(absRets, yy, function(ss) tail(cumprod(1+ss),1))
   df = cbind(as.data.frame(index(djiVol)), coredata(djiVol))
   colnames(df) = c("Year", "Volatility")
   gg = qplot(x=Year, y=Volatility, data=df, geom="line", colour=Volatility, xlab="Year", ylab="Volatility")
   gg = gg + theme_solarized(base_size=16, base_family="verdana", light=TRUE)

   return(list(plot=gg, dji=dji, dji.vol=djiVol, crystal.ball=zz, df=df))

The post 2018 Volatility Recap appeared first on Quintuitive.

To leave a comment for the author, please follow the link and comment on their blog: R – Quintuitive.

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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)