投資組合最佳化中的動態共變異數

Python 中的 GARCH 模型

Chelsea Yang

Data Science Instructor

什麼是共變異數

  • 說明兩個變數變動間的關係
  • 正共變異:同向移動
  • 負共變異:反向移動

共變異數範例

Python 中的 GARCH 模型

以 GARCH 估計動態共變異數

若兩個資產報酬的相關係數為 $\rho$,且波動度隨時間變動,分別為 $\sigma_1$ 與 $\sigma_2$:

$Covariance = \rho \cdot \sigma_1 \cdot \sigma_2$

covariance =  correlation * garch_vol1 * garch_vol2
Python 中的 GARCH 模型

在 Python 計算 GARCH 共變異數

步驟 1:擬合 GARCH 模型,取得各報酬序列的波動度

# gm_eur, gm_cad are fitted GARCH models
vol_eur = gm_eur.conditional_volatility
vol_cad = gm_cad.conditional_volatility

步驟 2:由已擬合的 GARCH 模型計算標準化殘差

resid_eur = gm_eur.resid/vol_eur
resid_cad = gm_cad.resid/vol_cad
Python 中的 GARCH 模型

在 Python 計算 GARCH 共變異數(續)

步驟 3:以標準化殘差的簡單相關作為 $\rho$

corr = np.corrcoef(resid_eur, resid_cad)[0,1]

步驟 4:以相關係數乘上波動度,得到 GARCH 共變異數。

covariance =  corr * vol_eur * vol_cad
Python 中的 GARCH 模型

現代投資組合理論(MPT)

  • Harry Markowitz 在其 1952 年論文「Portfolio Selection」首創
  • 善用分散化效果
  • 最適投資組合可在最低風險下達到最高報酬
Python 中的 GARCH 模型

MPT 直覺

  • 兩資產簡單投資組合的變異數:

_W1$*$ Variance1 + W2$*$ Variance2 + 2$*$W1$*$W2$*$Covariance _

 

  • 分散化效果:

將共變異數為負的資產放在同一組合中,可降低風險。

Python 中的 GARCH 模型

一起來練習吧!

Python 中的 GARCH 模型

Preparing Video For Download...