i trying optimize portfolio according specific level of risk. seems straightforward use fportfolio
, results getting not make sense. have spent hours trying figure out without luck.
base case (i.e., not constraints)
defaultspec <- portfoliospec() lppassets <- 100*lpp2005.ret[, c("sbi", "spi", "lmi", "mpi")] lppdata <- portfoliodata(data = lppassets, spec = defaultspec) port <- efficientportfolio(lppdata, defaultspec, constraints = "longonly") port@portfolio # $weights # sbi spi lmi mpi # 0.396009510 0.002142136 0.547715368 0.054132986 # $covriskbudgets # sbi spi lmi mpi # 0.396009510 0.002142136 0.547715368 0.054132986 # $targetreturn # mean mu # 0.006422759 0.006422759 # $targetrisk # cov sigma cvar var # 0.1038206 0.1038206 0.2186926 0.1684104 # $targetalpha # [1] 0.05 # $status # [1] 0 # slot "messages": # list()
when try set risk level 0.09, same answer.
defaultspec <- portfoliospec() settargetrisk(defaultspec) <- 0.09 # **this doesn't seem work** lppassets <- 100*lpp2005.ret[, c("sbi", "spi", "lmi", "mpi")] lppdata <- portfoliodata(data = lppassets, spec = defaultspec) port <- efficientportfolio(lppdata, defaultspec, constraints = "longonly") port@portfolio # object of class "fpfolioval" # slot "portfolio": # $weights # sbi spi lmi mpi # 0.396009510 0.002142136 0.547715368 0.054132986 # $covriskbudgets # sbi spi lmi mpi # 0.396009510 0.002142136 0.547715368 0.054132986 # $targetreturn # mean mu # 0.006422759 0.006422759 # $targetrisk # cov sigma cvar var # 0.1038206 0.1038206 0.2186926 0.1684104 # $targetalpha # [1] 0.05 # $status # [1] 0 # slot "messages": # list()
the "spec" says new level of risk targeted, results not change. not matter if set risk @ 0.09 or 0.12 or other value.
defaultspec # model list: # type: mv # optimize: maxreturn # estimator: covestimator # params: alpha = 0.05 = 1 # portfolio list: # portfolio weights: na # target return: na # target risk: 0.09 # risk-free rate: 0 # number of frontier points: 50 # status: na # optim list: # solver: solverquadprog # objective: portfolioobjective portfolioreturn portfoliorisk # options: meq = 2 # trace: false
what doing wrong? how set level of risk using fportfolio
in r?
from file fportfolio, appears if set risk target, might need use maxreturnportfolio. might need setoptimize(spec) <- 'maxreturn'.
copied file in r: "maximum return portfolio:
the function maxreturnportfolio returns portfolio maximal return fixed target risk."
Comments
Post a Comment