開始使用免費開始

GEV 風險估計

假設你在 2010 年 1 月 1 日持有 € 1,000,000 的 GE 股票。你希望根據 2008–2009 年的可用資料,為接下來一週「預期的」最大可能損失做準備。你假設 GE 的每週最大損失服從廣義極值(Generalized Extreme Value, GEV)分配。

為了建立預期損失的模型,你將在 GEV 分配下估計信賴水準為 99% 的 CVaR,並用它來計算在 2010 年 1 月需要準備、以覆蓋預期每週最大損失的金額。

工作空間中已提供 scipy.statsgenextreme 分配,以及 2008–2009 年期間 GE 的 losses

本練習屬於課程

Python 量化風險管理

檢視課程

練習說明

  • 以一週為區塊長度,找出 GE 資產價格的每週最大值。
  • 將 GEV 分配 genextreme 擬合到 weekly_maxima 資料。
  • 計算 99% 的 VaR,並以此求得 99% 的 CVaR 估計值。
  • 計算覆蓋預期每週最大損失所需的準備金金額。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Compute the weekly block maxima for GE's stock
weekly_maxima = losses.____("W").____()

# Fit the GEV distribution to the maxima
p = genextreme.____(____)

# Compute the 99% VaR (needed for the CVaR computation)
VaR_99 = genextreme.____(____, *p)

# Compute the 99% CVaR estimate
CVaR_99 = (1 / (1 - 0.99)) * genextreme.____(lambda x: x, 
           args=(p[0],), loc = p[1], scale = p[2], lb = ____)

# Display the covering loss amount
print("Reserve amount: ", 1000000 * CVaR_99)
編輯並執行程式碼