我正在尝试根据特定的风险水平优化投资组合。使用起来似乎很简单fPortfolio
,但我得到的结果没有意义。我花了几个小时试图解决这个问题,但没有任何运气。
基本情况(即,非约束)
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()
当我尝试将风险级别设置为 0.09 时,我得到了相同的答案。
defaultSpec <- portfolioSpec()
setTargetRisk(defaultSpec) <- 0.09 # **this doesn't seem to work**
lppAssets <- 100*LPP2005.RET[, c("SBI", "SPI", "LMI", "MPI")]
lppData <- portfolioData(data = lppAssets, spec = defaultSpec)
port <- efficientPortfolio(lppData, defaultSpec, constraints = "LongOnly")
port@portfolio
# An 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()
“规范”表示针对新的风险水平,但结果不会改变。我是否将风险设置为 0.09 或 0.12 或任何其他值都没有关系。
defaultSpec
# Model List:
# Type: MV
# Optimize: maxReturn
# Estimator: covEstimator
# Params: alpha = 0.05 a = 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
我究竟做错了什么?如何fPortfolio
在 R 中设置风险级别?