I'm using the timeSeries and fportfolio package in R to minimize the CVaR with different constraints for a given portfolio. Everything is working out so far. However, I can't manage to set a fixed mean return. When I use setTargetReturn(cvar_spec) <- 0.04
, as in the code below, the further code ignores it and calculates the CVAR for a smaller mean return. The last function, portfolioFrontier()
does not return the desired value pair as well. Does anyone know a way how to fix this?
library(timeSeries)
library(timeDate)
library(fPortfolio)
lppAssets3 <- 100 * LPP2005.RET[, 1:6]
colMeans(lppAssets3)
cvar_spec <- portfolioSpec()
setTargetReturn(cvar_spec) <- 0.04
setType(cvar_spec) <- "CVaR"
setSolver(cvar_spec) <- "solveRglpk.CVAR"
getOptimize(cvar_spec)
getSolver(cvar_spec)
box.1 <- "minW[1:6] = 0.0"
box.2 <- "maxW[1:6] = 0.5"
group.1 <- "minsumW[1:6] = 1.0"
group.2 <- "maxsumW[1:6] = 1.0"
constraints_cvar1 <- c(box.1, box.2, group.1, group.2)
minCVAR_Portfolio2 <- minriskPortfolio(lppAssets3,
cvar_spec,
constraints = constraints_cvar1
)
getWeights(minCVAR_Portfolio2)
CVAR_Portfolio2_frontier <- portfolioFrontier(lppAssets3,
cvar_spec,
constraints = constraints_cvar1
)