BaşlayınÜcretsiz Başlayın

Backtest with periodic rebalancing

Now we will run the backtest using the portfolio specification created in the last exercise with quarterly rebalancing to evaluate out-of-sample performance. The other backtest parameters we need to set are the training period and rolling window. The training period sets the number of data points to use for the initial optimization. The rolling window sets the number of periods to use in the window. This problem can be solved with a quadratic programming solver so we will use "ROI" for the optimization method.

Bu egzersiz

Intermediate Portfolio Analysis in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Run the optimization with quarterly rebalancing. Set the training period and rolling window to use 5 years of data. Assign the results to a variable named opt_rebal_base.
  • Print the results of the optimization.
  • Chart the weights.
  • Compute the portfolio returns using Return.portfolio. Assign the returns to a variable named returns_base.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.


# Run the optimization
opt_rebal_base <- optimize.portfolio.rebalancing(R = ___, 
                                                 portfolio = ___, 
                                                 optimize_method = "ROI", 
                                                 rebalance_on = ___, 
                                                 training_period = ___,
                                                 rolling_window = ___)

# Print the results


# Chart the weights


# Compute the portfolio returns
returns_base <- Return.portfolio(R = ___, weights = ___)
colnames(returns_base) <- "base"
Kodu Düzenle ve Çalıştır