Asset allocation notification

Asset allocation notification

I’m in the midst of automating/ guiding my life with algorithms (largely inspired by Ray Dalio) - and 1 of the guidelines that I set is on asset allocation,

  • Emerging market and Developed Market should be of the same proportion
  • Bonds + Cash proportion should be equivalent to my age. This can deviate in times of crisis when I want to be more opportunistic.

If it deviates from the portfolio policy statement, it will send me a pushover notification to my phone:)

Here is a simple example of it works.

/post/img/asset_notify.jpeg

You may find my code below. Briefly this is what it does,

  • It ssh into my googlesheet
  • Pull out the asset allocation and compare against the policy statements
  • If it deviates, it will send me a notification
  • This is scheduled via a cronjob in linux that runs every midnight
#Comment on asset allocation
dat = gs_title("Investment")
gs_ws_ls(dat)   #tab names
data <- gs_read(ss=dat, ws = "asset_allocation1", skip=0)
data = as.data.frame(data)

if(data$Prop[which(data$Assets == "World + Developed (ex real estate)")] > data$Prop[which(data$Assets == "Emerging")]){
  
  msg = "Bro, you are overweight in Developed. Shift to Emerging\n"
  msg = paste(msg, "World is %", 100 * data$Prop[which(data$Assets == "World + Developed (ex real estate)")])
  msg = paste(msg, "Emerging is %", 100 * data$Prop[which(data$Assets == "Emerging")])
  
  pushover(message = msg, 
           user = Sys.getenv("pushover_user"), app = Sys.getenv("pushover_app")
  )
}

if(data$Prop[which(data$Assets == "Emerging")] > data$Prop[which(data$Assets == "World + Developed (ex real estate)")]){
  
  msg = "Bro, you are overweight in Emerging. Shift to Developed\n"
  msg = paste(msg, "World is %", 100 * data$Prop[which(data$Assets == "World + Developed (ex real estate)")])
  msg = paste(msg, "Emerging is %", 100 * data$Prop[which(data$Assets == "Emerging")])
  
  pushover(message = msg, 
           user = Sys.getenv("pushover_user"), app = Sys.getenv("pushover_app")
  )
}

if(100 * (data$Prop[which(data$Assets == "Bonds")] + data$Prop[which(data$Assets == "Cash")]) > data$Prop[which(data$Assets == "Age")]){
  
  msg = "Bro, you are overweight in Bonds and Cash relative to your age. Shift it out!!!\n"
  msg = paste(msg, "Bonds is %", 100 * data$Prop[which(data$Assets == "Bonds")])
  msg = paste(msg, "Cash is %", 100 * data$Prop[which(data$Assets == "Cash")])
  
  pushover(message = msg, 
           user = Sys.getenv("pushover_user"), app = Sys.getenv("pushover_app")
  )
}

if(100 * (data$Prop[which(data$Assets == "Bonds")] + data$Prop[which(data$Assets == "Cash")]) < data$Prop[which(data$Assets == "Age")]){
  
  msg = "Bro, you are underweight in Bonds and Cash relative to your age. Move out from equities!!!\n"
  msg = paste(msg, "Bonds is %", 100 * data$Prop[which(data$Assets == "Bonds")])
  msg = paste(msg, "Cash is %", 100 * data$Prop[which(data$Assets == "Cash")])
  
  pushover(message = msg, 
           user = Sys.getenv("pushover_user"), app = Sys.getenv("pushover_app")
  )
}

Related

comments powered by Disqus