How to add a VaR constraint to the portfolio optimization function?
I'm trying to optimize a portfolio using PortfolioAnalytics maximizing the Sharpe Ratio, given the following constraints:
- The sum of the weights must equal 1.
- The maximum weight per asset must not exceed 0.1.
- The maximum VaR of the porfolio must not exceed 0.025.
I have tried adding the VaR constraint...
# As type = "risk".
portf <- PortfolioAnalytics::add.constraint(portf, type = "risk",
return_target = -0.025,
sense = "<=",
name = "VaR")
######
portf <- PortfolioAnalytics::add.constraint(portf, type = "risk", name = "VaR",
max = 0.025)
# As type = "return".
portf <- PortfolioAnalytics::add.constraint(portf, type = "return",
return_type = "VaR",
return_threshold = -0.025,
sens = "<=")
####
portf <- PortfolioAnalytics::add.constraint(portf, type = "return", name = "VaR",
max = 0.025)
# As add.objective(portf, type = "risk")
port <- PortfolioAnalytics::add.objective(port, type = "risk",
name = "VaR", max = 0.025)
Any help would be greatly appreciated.
Thanks in advance!