Skew of Bonds

[This article was first published on Timely Portfolio, 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.

As the researchpuzzler highlights in “a bad bet”, US bonds were a popular subject at the CFA Institute Annual Conference.  While US Bonds have been in an amazing 30 year run (see previous posts Lattice Explore Bonds, Bond Market as a Casino Game Part 1, Calmar Ratio 1.37 over the past 20 years), I think many positive skew-chasing market participants are not aware of the frequency of negative skew in bond returns.  As a public service, I thought I should issue a negative skew alert.

From TimelyPortfolio

R code from GIST:

require(quantmod)
require(PerformanceAnalytics)
#load my barclays agg file
#if you do not have access to Barclays Agg return then you can
#use VBMFX as a proxy
portfolio <- read.csv("C:\\Users\\Kent.TLEAVELL_NT\\Documents\\old\\R\\barclaysagg.csv",stringsAsFactors=FALSE)
portfolio <- portfolio[2:(NROW(portfolio)-1),2:NCOL(portfolio)]
portfolio <- portfolio[,c(1,4)]
#since export has duplicate colnames we need to remove the .1 added
#colnames(portfolio) <- substr(colnames(portfolio),1,nchar(colnames(portfolio))-2)
#transform to get in appropriate xts form
len <- nchar(portfolio[,1])
xtsdate <- paste(substr(portfolio[,1],len-3,len),"-",
ifelse(len==9,"0",""),substr(portfolio[,1],1,len-8),"-01",sep="")
portfolio.xts <- xts(data.matrix(portfolio[,2:NCOL(portfolio)]),order.by=as.Date(xtsdate))
portfolio.xts <- portfolio.xts/100
portfolio.xts[1,]<-0
#########start skew analysis################################################
colnames(portfolio.xts) <- "BarclaysAgg"
#get rolling skew
skew <- apply.rolling(portfolio.xts[,1],FUN=skewness,width=36,by=1)
#combine skew with ROC
skew.roc <- merge(skew,
ROC(apply(portfolio.xts[,1]+1,MARGIN=2,FUN=cumprod),type="discrete",n=36))
colnames(skew.roc)<-c("skew","roc")
#plot skew and roc
chart.TimeSeries(skew.roc, main="Barclays US Aggregate Skew and ROC (Rolling 36-month)",
legend.loc="topright")
view raw bond skew.r hosted with ❤ by GitHub

To leave a comment for the author, please follow the link and comment on their blog: Timely Portfolio.

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)