1

我尝试使用 R 中的“PortfolioAnalytics”包对不同的投资组合优化方法进行回测。首先,我运行“标准”优化方法,然后使用“MASS”对资产收益的方差-协方差矩阵使用两种不同的稳健估计进行优化“ 包裹。

最后,我还想对optimize.portfolio.rebalancing资产回报时刻使用“boudt”估计。这将返回两条警告消息和有缺陷的投资组合输出:

1: In Return.portfolio(ret, weights = extractWeights(opt_Boudt)) :
  number of assets in beginning_weights is less than number of columns in returns, so subsetting returns.
2: In Return.portfolio.geometric(R = R, weights = weights, wealth.index = wealth.index,  :
  The weights for one or more periods do not sum up to 1: assuming a return of 0 for the residual weights

这是我的可重现代码

library(xts)
library(PortfolioAnalytics)
library(ROI)
library(MASS)

data("edhec")
ret = edhec[,1:6]

port <- portfolio.spec(assets = colnames(ret))
port <- add.constraint(port, "long_only")
port <- add.constraint(port, "full_investment")
port <- add.objective(port, type = "Risk", name = "StdDev")
port <- add.objective(port, type = "return", name = "mean")


#Standard Optimization
opt_norm <- optimize.portfolio.rebalancing(R = ret, portfolio = port, optimize_method = "ROI", rebalance_on = "months", training_period = 60, rolling_window = NULL)
summary(opt_norm)
rr_norm <- Return.portfolio(ret, weights = extractWeights(opt_norm))
charts.PerformanceSummary(rr_norm)

#Robust MCD-VarCov Optimization
custom_fun <- function(R, portfolio, rob_method = "mcd"){
  out <- list()
  out$sigma <- cov.rob(R, method = rob_method)
  return(out)
}

opt_MCD <- optimize.portfolio.rebalancing(R = ret, portfolio = port, optimize_method = "ROI", momentFUN = custom_fun, rob_method = "mcd", rebalance_on = "months", training_period = 60, rolling_window = NULL)
summary(opt_MCD)
rr_MCD <- Return.portfolio(ret, weights = extractWeights(opt_MCD))
charts.PerformanceSummary(rr_MCD)

#Robust MVE-VarCov Optimization
opt_MVE <- optimize.portfolio.rebalancing(R = ret, portfolio = port, optimize_method = "ROI", momentFUN = custom_fun, rob_method = "mve", rebalance_on = "months", training_period = 60, rolling_window = NULL)
summary(opt_MVE)
rr_MVE <- Return.portfolio(ret, weights = extractWeights(opt_MVE))
charts.PerformanceSummary(rr_MVE)

#Boudt Optimization
boudt_moments <- set.portfolio.moments(R = ret, portfolio = port, method = "boudt", k = 1)
opt_Boudt <- optimize.portfolio.rebalancing(R = ret, portfolio = port, optimize_method = "ROI", momentFUN = boudt_moments, rebalance_on = "months", training_period = 60, rolling_window = NULL) 
rr_Boudt <- Return.portfolio(ret, weights = extractWeights(opt_Boudt))
charts.PerformanceSummary(rr_Boudt)

我现在有两个单独的问题

  1. 前三个优化回测(1. Standard、2. MCD-VarCov、3. MVE-VarCov)怎么可能返回完全相同的结果,这可以在比较性能图时看到,例如?
  2. 在尝试使用“boudt”估计资产回报时刻时,我做错了什么?

由于这是我第一次在这里提问,我也很乐意收到有关如何改进在 stackoverflow 上提问的意见。

谢谢大家!

4

0 回答 0