Exercise

The time series of weights

In the previous exercise, you explored the functionality of the Return.portfolio() function and created portfolios using two strategies. However, by setting the argument verbose = TRUE in Return.portfolio() you can create a list of beginning of period (BOP) and end of period (EOP) weights and values in addition to the portfolio returns, and contributions.

You can access these from the resultant list-object created from Return.portfolio(). The resultant list contains $returns, $contributions, $BOP.Weight, $EOP.Weight, $BOP.Value, and $EOP.Value.

In this exercise, you will recreate the portfolios you made in the last exercise but extend it by creating a list of calculations using verbose = TRUE. You will then visualize the end of period weights of Apple.

The object returns is pre-loaded in your workspace.

Instructions

100 XP
  • Define the vector eq_weights for two equally weighted assets.
  • Create a portfolio of returns by using the buy and hold strategy and setting verbose = TRUE. Call this pf_bh.
  • Create a portfolio of returns using the monthly rebalancing strategy and setting verbose = TRUE. Call this pf_rebal.
  • Create a new object called eop_weight_bhusing the end of period weights of pf_bh.
  • Create a new object called eop_weight_rebal using the end of period weights of pf_rebal.
  • Plot the end of period weights of Apple in eop_weight_bh using plot.zoo(), and the end of period weights of Apple in eop_weight_rebal using plot.zoo(). par(mfrow = c(2, 1), mar = c(2, 4, 2, 2)) is used to organize the plots you create. Do not alter this code.