Seeking R code for backtesting a low-volatility trading strategy of stock returns.
There is an estimation period for the stocks, e.g. 24 months. Then for all stocks a 24-month standard deviation (sd) is calculated and the stocks are ranked. Then they are divided into five equally sized portfolios based on rank (low-high sd). A 1-month holding period return is calculated for the stock portfolios of the ranked stocks. This is then repeated n times, so that we get a time-series of returns for the five portfolios. N length is 12 months x 20 years.