3

我正在尝试根据特定的风险水平优化投资组合。使用起来似乎很简单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 中设置风险级别?

4

3 回答 3

1

从 fPortfolio 的帮助文件中可以看出,如果您设置了风险目标,您可能需要使用 maxreturnPortfolio。您可能还需要 setOptimize(spec) <- 'maxReturn'。

复制自 R 中的帮助文件:“最大回报组合:

函数 maxreturnPortfolio 返回具有固定目标风险的最大回报的投资组合。”

于 2015-05-22T02:02:00.703 回答
1

当您将 maxreturnPortfolio() 与允许卖空结合使用时,优化器将成功地针对您通过 setTargetRisk 提供的风险级别并相应地调整权重。此外,您不想将 LPP2005.RET 缩放 100。

library(fPortfolio)
defaultSpec <- portfolioSpec()
setTargetRisk(defaultSpec) <- 0.09
setSolver(defaultSpec)= "solveRshortExact" 
lppAssets <- LPP2005.RET[, c("SBI", "SPI", "LMI", "MPI")]
lppData <- portfolioData(data = lppAssets, spec = defaultSpec)
port <- maxreturnPortfolio(lppData, defaultSpec, constraints = "Short")
port@portfolio

您现在得到一个目标风险级别为 0.09 的解决方案:

An object of class "fPFOLIOVAL"
Slot "portfolio":
$weights
         SBI          SPI          LMI          MPI 
-43.38872554  10.24063734  34.16040358  -0.01231538 

$covRiskBudgets
          SBI           SPI           LMI           MPI 
 0.2599262930  0.7653635547 -0.0246663061 -0.0006235416 

$targetReturn
      mean         mu 
0.01048478 0.01048478 

$targetRisk
      Cov     Sigma      CVaR       VaR 
0.0900000 0.0900000 0.2048887 0.1397806 

$targetAlpha
[1] 0.05

$status
[1] 0


Slot "messages":
list()
于 2016-04-18T16:18:17.267 回答
1

我推荐阅读作者写的这本书:fPortfolio book

于 2021-03-12T15:52:25.040 回答