風險估計的尺度調整
前面練習算出的 VaR(95) 僅是單日的風險值。若要估計更長時間範圍的 VaR,可以如同調整波動度一樣,以時間的平方根來縮放:
$$ \text{VaR(95)}_{\text{t days}} = \text{VaR(95)}_{\text{1 day}} * \sqrt{t} $$
工作環境中已提供上一題的 StockReturns_perc 與 var_95。請用這些資料來估計 USO 原油 ETF 在未來 1 到 100 天的 VaR。我們也已定義好 plot_var_scale() 函式,用來繪製未來 1 到 100 天的 VaR。
本練習屬於課程
Python 投資組合風險管理入門
練習說明
- 使用
range()從 0 迴圈到 100(不含 100)。 - 在每個索引位置,將
forecasted_values的第二欄設為預測的 VaR,做法是用np.sqrt()將var_95乘上i + 1的平方根。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Aggregate forecasted VaR
forecasted_values = np.empty([100, 2])
# Loop through each forecast period
for i in ____:
# Save the time horizon i
forecasted_values[i, 0] = i
# Save the forecasted VaR 95
forecasted_values[i, 1] = ____
# Plot the results
plot_var_scale()