Japanese Government Bonds (JGB) Total Return Series

[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.

In a follow up to Yen and JGBs Short-Term vs Long Term and a series of posts on Japan, I thought the Bloomberg article “Japan Pension Fund’s Bonds Too Many If Abe Succeeds, Mitani Says” was particularly interesting.  It is difficult to find a total return series for the JGBS, so here is an example of how we might construct it in R with the JGB 9 year. Using the 9 year gets us about a decade more data than the 10 year.  The calculation is not perfect but it gets us very close.

The Japanese Pension Fund (GPIF) has been spoiled by a very pleasant ride with their JGBs.

From TimelyPortfolio

R code from GIST:

#get Japan yield data from the Ministry of Finance Japan
#data goes back to 1974
require(RQuantLib)
require(PerformanceAnalytics)
#get data from the Japanese Ministry of Finance
url <- "http://www.mof.go.jp/english/jgbs/reference/interest_rate/"
filenames <- paste("jgbcme",c("","_2010","_2000-2009","_1990-1999","_1980-1989","_1974-1979"),".csv",sep="")
#load all data and combine into one jgb data.frame
jgb <- read.csv(paste(url,filenames[1],sep=""),stringsAsFactors=FALSE)
for (i in 2:length(filenames)) {
jgb <- rbind(jgb,read.csv(paste(url,"/historical/",filenames[i],sep=""),stringsAsFactors=FALSE))
}
#now clean up the jgb data.frame to make a jgb yield xts series
jgb.xts <- as.xts(data.matrix(jgb[,2:NCOL(jgb)]),order.by=as.Date(jgb[,1]))
#initialize the price return object
JGB9pricereturn<-jgb.xts[,"X9"]
JGB9pricereturn[1,1]<-0
colnames(JGB9pricereturn)<-"PriceReturn-JGB9"
#use quantlib to price the JGB 9 year
#9 year has a longer history than the 10 year so we'll use 9 year
for (i in 1:(NROW(jgb.xts[,"X9"])-1)) {
JGB9pricereturn[i+1,1]<-FixedRateBondPriceByYield(yield=jgb.xts[i+1,"X9"]/100,issueDate=Sys.Date(),
maturityDate= advance("Japan", Sys.Date(), 9, 3),
rates=jgb.xts[i,"X9"]/100,period=2)[1]/100-1
}
#total return will be the price return + yield/12 for one month
JGB9totalreturn<-JGB9pricereturn+lag(jgb.xts[,"X9"],k=1)/250/100
colnames(JGB9totalreturn)<-"TotalReturn-JGB9"
JGB9totalreturn[1,1] <- 0
JGB9cumul <- cumprod(JGB9totalreturn+1)
charts.PerformanceSummary(JGB9totalreturn,
main=NA,
xlab=NA)
title(main="Japanese Government Bond (JGB) 9 Year Total Return",adj=0.04,outer=TRUE,line=-1.5)

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)