歡迎加入本課程!

R 中級投資組合分析

Ross Bennett

Instructor

你將學到什麼

  • 延伸「Introduction to Portfolio Analysis in R」{{1}} 的基礎觀念。

  • 探索投資組合最佳化流程中的進階概念

  • 使用 R 套件 PortfolioAnalytics 解決貼近真實情境的投資組合最佳化問題

R 中級投資組合分析

現代投資組合理論

  • 現代投資組合理論(MPT)由 Harry Markowitz 於 1952 年提出。

  • MPT 指出投資人的目標是在既定風險下,最大化投資組合的期望報酬。

  • 常見目標:

    • 最大化每單位風險的報酬

    • 最小化風險衡量

R 中級投資組合分析

平均-標準差範例:設定

library(PortfolioAnalytics)
data(edhec)
data <- edhec[,1:8]
# Create the portfolio specification
port_spec <- portfolio.spec(colnames(data))
port_spec <- add.constraint(portfolio = port_spec, type = "full_investment")
port_spec <- add.constraint(portfolio = port_spec, type = "long_only")
port_spec <- add.objective(portfolio = port_spec, type = "return", name = "mean")
port_spec <- add.objective(portfolio = port_spec, type = "risk", name = "StdDev")
R 中級投資組合分析
**************************************************
PortfolioAnalytics Portfolio Specification 
**************************************************
Call:
portfolio.spec(assets = colnames(data))

Number of assets: 8 
Asset Names
[1] "Convertible Arbitrage"  "CTA Global"             "Distressed Securities" 
[4] "Emerging Markets"       "Equity Market Neutral"  "Event Driven"          
[7] "Fixed Income Arbitrage" "Global Macro"          

Constraints
Enabled constraint types
        - full_investment 
        - long_only 

Objectives:
Enabled objective names
        - mean 
        - StdDev
R 中級投資組合分析

平均-標準差範例:最佳化

# Run optimization and chart results in risk-reward space
opt <- optimize.portfolio(data, 
                   portfolio = port_spec,
                   optimize_method = "random",
                   trace = TRUE)
chart.RiskReward(opt,
                 risk.col = "StdDev",
                 return.col = "mean",
                 chart.assets = TRUE)
R 中級投資組合分析

平均-標準差範例:最佳化

ch1_vid1_slides.033.png

R 中級投資組合分析

一起來練習吧!

R 中級投資組合分析

Preparing Video For Download...