0

我正在尝试使用简单的最小波动率和使用 edhec 数据的盒子约束来运行年度再平衡,但是在使用 60 个月的滚动窗口时它在 2012-12-31 失败,所以我在下面隔离了那个时期并且问题仍然存在:

# Load libraries
library(PortfolioAnalytics)
library(PerformanceAnalytics)

# Load edhec returns
data(edhec)
asset_returns <- edhec["2007-12-31/2012-12-31"]

# Create the portfolio specification
base_port_spec <- portfolio.spec(assets = colnames(asset_returns))
# Add a full investment constraint such that the weights sum to 1
base_port_spec <- add.constraint(base_port_spec,
                                 type = "full_investment")
# Add a long only constraint such that the weight of an asset is between 5% and 40%
base_port_spec <- add.constraint(base_port_spec,
                                 type = "box",
                                 min = 0.05, max = 0.4)
# Add an objective to minimize portfolio standard deviation
base_port_spec <- add.objective(base_port_spec,
                                type = "risk",
                                name = "StdDev")

# Run the optimization with periodic rebalance
opt_base <- optimize.portfolio(R = asset_returns,
                               optimize_method = "ROI",
                               portfolio = base_port_spec)

print(extractWeights(opt_base))

我检查了协方差矩阵,一切似乎都很好。特征值是正的,并且两者都solve()产生MASS::ginv()结果,所以我很确定协方差矩阵很好。任何其他想法为什么它会在这个特定时间段内失败?我想也许投资回报率和盒子约束不兼容,但每隔 60 个月就可以正常工作,这是唯一失败的。

谢谢。

4

0 回答 0