馬可維茲投資組合

Python 投資組合風險管理入門

Dakota Wixom

Quantitative Analyst | QuantCourse.com

隨機產生的 100,000 個投組

Python 投資組合風險管理入門

夏普比率

夏普比率用來衡量「風險調整後報酬」。

計算 1966 年版夏普比率:

$$ S = \frac{ R_a - r_f }{\sigma_a} $$

  • S:夏普比率
  • $ R_a $:資產報酬
  • $ r_f $:無風險利率
  • $ \sigma_a $:資產波動度
Python 投資組合風險管理入門

有效前緣

Python 投資組合風險管理入門

馬可維茲投組

有效前緣上的任一點都是最適投組。

這兩個常見點稱為「馬可維茲投組」:

  • MSR:最大夏普比率投組
  • GMV:全域最小波動度投組

Python 投資組合風險管理入門

選擇投組

要怎麼選最佳投組?

  • 選在有效前緣邊界上的投組
  • 若能承受較高風險,就有機會換取較高報酬
Python 投資組合風險管理入門

在 Python 中選出 MSR

假設有隨機投組的 DataFrame df,包含 VolatilityReturns 欄:

numstocks = 5
risk_free = 0
df["Sharpe"] = (df["Returns"] - risk_free) / df["Volatility"]
MSR = df.sort_values(by=['Sharpe'], ascending=False)
MSR_weights = MSR.iloc[0, 0:numstocks]
np.array(MSR_weights)
array([0.15, 0.35, 0.10, 0.15, 0.25])
Python 投資組合風險管理入門

過去績效不保證未來報酬

雖然最大夏普比率投組聽起來不錯,但實務上,報酬非常難以預測。

Python 投資組合風險管理入門

在 Python 中選出 GMV

假設有隨機投組的 DataFrame df,包含 VolatilityReturns 欄:

numstocks = 5
GMV = df.sort_values(by=['Volatility'], ascending=True)
GMV_weights = GMV.iloc[0, 0:numstocks]
np.array(GMV_weights)
array([0.25, 0.15, 0.35, 0.15, 0.10])
Python 投資組合風險管理入門

一起來練習吧!

Python 投資組合風險管理入門

Preparing Video For Download...