How do I add a VaR constraint to PortfolioAnalytics optimization function in R?

52 Views Asked by At

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:

  1. The sum of the weights must equal 1.
  2. The maximum weight per asset must not exceed 0.1.
  3. 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!

0

There are 0 best solutions below