Skip to content
All library documents

Setting Training and Rolling Windows for Walk-Forward Portfolio Optimization

Article Quant Q&A · Author: Jordan Wrong

Summary

The document asks how the training_period and rolling_window arguments in PortfolioAnalytics’ rebalancing optimizer control out-of-sample testing. The author describes a monthly rebalancing strategy using daily returns and wants to optimize on an initial block of observations, then assess performance on a later block. They propose values for the two parameters but provide no answer or confirmed configuration.

The central practical issue is matching the optimizer’s window lengths to the data frequency, rebalance schedule, and intended train-test split. A training window sets how much historical data is used for each optimization, while the rolling window governs the width of data considered as the procedure advances; exact behavior should be checked against the package documentation and the rebalancing dates. The proposed daily ranges cannot be confirmed from this question alone, and the document gives no backtest results or guidance on avoiding other sources of overfitting.

Key ideas

  • Walk-forward analysis separates portfolio optimization data from later performance evaluation.
  • The training window controls the observations used to estimate portfolio weights.
  • The rolling window affects how the historical sample changes as rebalancing proceeds.
  • Window settings must be interpreted in the data frequency and rebalancing schedule used.

Tags

Full text
# Walk Forward Analysis Using Portfolio Analytics R


# Walk Forward Analysis Using Portfolio Analytics R












I am learning how to use the Portfolio Analytics package in R and I am concerned with overfitting the data for the optimization.

The optimize.portfolio.rebalancing() function has 2 parameters that might help with this:

training_period item{training_period}{an integer of the number of periods to use as a training data in the front of the returns data}

rolling_window \item{rolling_window}{an integer of the width (i.e. the number of periods) of the rolling window, the default of NULL will run the optimization using the data from inception.}

There is also some documentation with an example from CRAN. Here is the Link Pg.84

However, I am having a little difficulty understanding exactly what these do. In my script, I am rebalancing monthly and using daily data. I would like to do something like a Walk Forward Analysis - Optimize on 0:60 days and then test performance on 61:70 days.

Would my parameters be set to: rolling_window = 70; training_period = 60 ?

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.