Sixty-Forty rule

Quick blog post about the sixty forty rule rebalanced annually.
As always this is not investment advice.

Whipped it up using SPY for stocks and BND for bonds, I used adjusted closes, you could use closes or whatever you like, you can also change rebal to a different number of days.

library(quantmod)
library(PerformanceAnalytics)
getSymbols("SPY")
getSymbols("BND")
my_matrix = merge.xts(ROC(Ad(BND),type='discrete'),ROC(Ad(SPY),type='discrete'))['2008/2014']
##60/40
init_w = c(0.4,0.6)
wmat = xts(matrix(ncol=2,nrow=nrow(my_matrix)),order.by=index(my_matrix))
##(rebal in days)
rebal = 252
wmat[1,] = init_w
for(i in 2:nrow(wmat)){
  if(i%%rebal==0){wmat[i,]=init_w}else{
  wmat[i,] = wmat[i-1,]*(1+my_matrix[i-1,] )
  wmat[i,] = wmat[i,]/sum(wmat[i,])
  }
}
portfolio_performance = xts(rowSums(wmat*my_matrix),order.by=index(my_matrix))
colnames(portfolio_performance) = c('sixty_forty')
chart.CumReturns(merge.xts(portfolio_performance,my_matrix),legend.loc='topleft',wealth.index=TRUE)

Created by Pretty R at inside-R.org

 

sixty forty

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: