Hàm mục tiêu

Phân tích danh mục đầu tư nâng cao với R

Ross Bennett

Instructor

Hàm mục tiêu

Hàm mục tiêu tính giá trị mục tiêu. Trong PortfolioAnalytics, hàm mục tiêu có thể là bất kỳ hàm R hợp lệ nào.

  • Thước đo rủi ro danh mục phổ biến

    • độ lệch chuẩn, expected shortfall, value at risk, đóng góp thành phần vào rủi ro, mức sụt giảm tối đa, Sharpe Ratio
  • Thước đo hiệu suất tương đối so với benchmark

    • information ratio, tracking error, lợi nhuận vượt trội, mức sụt giảm tương đối tối đa
Phân tích danh mục đầu tư nâng cao với R

Hàm mục tiêu tùy chỉnh

Hàm do người dùng định nghĩa làm hàm mục tiêu

  • Quy ước tên tham số:

    • R cho lợi nhuận tài sản

    • weights cho tỷ trọng danh mục

    • mu, sigma, m3, m4 cho các moment

  • Trả về một giá trị đơn

Phân tích danh mục đầu tư nâng cao với 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)
}
Phân tích danh mục đầu tư nâng cao với 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))
Phân tích danh mục đầu tư nâng cao với R

Hãy thực hành!

Phân tích danh mục đầu tư nâng cao với R

Preparing Video For Download...