我正在尝试使用投资组合分析优化来最大化主动回报并最小化主动风险。这可以使用这个包吗?我正在尝试最小化活动重量。所以 Min(Portw -Benchw)*Cov。作为目标函数的一部分,有没有办法添加板凳重量?
这是我目前的代码..任何帮助将不胜感激!谢谢你。
#this dataframe is the current benchmark weightings. i would like to
#specify my objective function so that i am minimizing the active risk, not
#total risk. is there a way to feed the benchmark weights into the
#add.objective function?
BenchWeight <- arrange(BenchWeight,Product)%>%
spread(Product,Weight)
#CovMatrix is a dataframe turned into xts object with 120 daily returns on
#various bond market sectors.
CovMatrix <- select(ExcessReturns, Date,Product,Excess_Returns_Daily)%>%
spread(Product,Excess_Returns_Daily)%>%
select(-Universal)%>%
arrange(desc(Date))%>%
slice(1:120)
optimdata <- xts(CovMatrix[,-1], order.by = CovMatrix[,1])
optimweight <- portfolio.spec(colnames(optimdata))
optimweight <- add.constraint(optimweight, type= "weight_sum", min_sum=0,
max_sum=1)
optimweight <- add.constraint(optimweight, type = "long_only")
optimweight <- add.objective(optimweight, type="return", name = "mean")
optimweight <- add.objective(optimweight, type = "risk",name = "StdDev",
target = 0.5)
optimweight1 <- optimize.portfolio(optimdata,optimweight, optimize_method
= "ROI")