ฟังก์ชันวัตถุประสงค์

การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R

Ross Bennett

Instructor

ฟังก์ชันวัตถุประสงค์

ฟังก์ชันวัตถุประสงค์ใช้คำนวณค่าวัตถุประสงค์ ใน PortfolioAnalytics สามารถใช้ฟังก์ชัน R ที่ถูกต้องใดก็ได้

  • ตัวชี้วัดความเสี่ยงพอร์ตโฟลิโอที่ใช้บ่อย

    • standard deviation, expected shortfall, value at risk, component contribution to risk, maximum drawdown, Sharpe Ratio
  • ตัวชี้วัดผลการดำเนินงานเทียบ benchmark ที่ใช้บ่อย

    • information ratio, tracking error, excess return, maximum relative drawdown
การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R

ฟังก์ชันวัตถุประสงค์แบบกำหนดเอง

ฟังก์ชันที่ผู้ใช้กำหนดเองในฐานะฟังก์ชันวัตถุประสงค์

  • การตั้งชื่ออาร์กิวเมนต์:

    • R สำหรับผลตอบแทนสินทรัพย์

    • weights สำหรับน้ำหนักพอร์ตโฟลิโอ

    • mu, sigma, m3, m4 สำหรับโมเมนต์

  • คืนค่าเดียว

การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R
# Annualized sharpe ratio
sr_annualized <- function(R, weights, sigma, scale, rfr){

    # Geometric annualized return
    r <- Return.annualized(Return.portfolio(R, weights), scale = scale)
    # Annual excess return
    re <- r - rfr

    # Annualized portfolio standard deviation
    pasd <- sqrt(as.numeric(t(weights) %*% 
                 sigma %*% weights)) * sqrt(scale)

    return(re / pasd)
}
การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R
data(edhec)
asset_returns <- edhec[,1:4]

# Setup spec and add constraints port_spec <- portfolio.spec(assets = colnames(asset_returns)) port_spec <- add.constraint(portfolio = port_spec, type = "full_investment") port_spec <- add.constraint(portfolio = port_spec, type = "long_only")
# Add custom objective function port_spec <- add.objective(portfolio = port_spec, type = "return", name = "sr_annualized", arguments = list(scale = 12, rfr = 0.02))
การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R

มาฝึกกันเถอะ!

การวิเคราะห์พอร์ตโฟลิโอระดับกลางใน R

Preparing Video For Download...