我正在尝试执行标准的投资组合优化,但限制允许投资组合的最终权重偏离一组初始权重。我用这个PortfolioAnalytics
包做这个,下面的代码是一个没有任何错误的 MWE。
# load packages and data
library(quadprog)
library(PortfolioAnalytics)
data(edhec)
dat <- edhec[,1:4]
# add initial weights to initial portfolio
funds <- c("Convertible Arbitrage" = 0.4, "CTA Global" = 0.3, "Distressed Securities" = 0.2, "Emerging Markets" = 0.1)
init.portf <- portfolio.spec(assets=funds)
# standard constraints & objectives
init.portf <- add.constraint(portfolio=init.portf, type="box", min_w=0, min_sum=0.99, max_sum=1.01)
init.portf <- add.objective(portfolio=init.portf, type="return", name="mean")
init.portf <- add.objective(portfolio=init.portf, type="risk", name="StdDev")
# TURNOVER CONSTRAINT (MATTER OF THIS THREAD)
init.portf <- add.constraint(portfolio=init.portf, type="turnover", turnover_target=0)
# optimize portfolio
opt.portf <- optimize.portfolio(R=dat, portfolio=init.portf, trace=TRUE, optimize_method="random")
# check the weights of optimized portfolio
print.default(opt.portf$weights)
turnover_target
是0
,所以输出权重应该与输入权重相同,(0.4, 0.3, 0.2, 0.1)
但它们的权重相等(0.25, 0.25, 0.25, 0.25)
。等权重是默认的初始权重,所以不知何故,我设置的初始权重似乎无法识别。但是查看add.constraint或rolling_constraint的文档并没有多大帮助。看起来好像一切都应该正常工作。他们定义初始权重的方式与portfolio.spec的文档相匹配
有谁知道为什么我的初始权重被营业额约束忽略了?