開始使用免費開始

為選擇權投資組合估計 VaR 與 ES

現在你要利用 hslosses 中以歷史模擬得到的損益,來為歐式買權投資人估計 VaR 與 ES。

同樣地,你會用兩種方法進行。首先,使用以樣本分位數為基礎的非參數方法估計 VaR,並計算超過同一分位數的值的平均來估計 ES。

接著,將這些估計值與假設 hslosses 服從常態分配時得到的結果相比。就像前一個練習,這個假設並不好,你應該比較兩組估計,看看哪一組較為保守。

本練習屬於課程

R 的量化風險管理

檢視課程

練習說明

  • 使用 quantile() 估計 hslosses 分配的 99.5% 樣本分位數。
  • 透過對至少與 VaR 估計一樣大的 hslosses 取平均來估計 99.5% 的 ES(此步驟已為你完成)。
  • 使用適當的函式估計 hslosses 的平均值與標準差,並分別指派給 musigma
  • 使用 qnorm() 搭配計算出的平均與標準差,求出常態分配的 99.5% 分位數。
  • 使用 ESnorm() 搭配計算出的平均與標準差,求出常態分配的 99.5% ES。

動手互動練習

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

# Estimate the 99.5% percentile of the distribution


# Estimate the 99.5% ES
mean(hslosses[hslosses >= quantile(hslosses, 0.995)])

# Estimate the mean and standard deviation of hslosses



# Compute the 99.5% quantile of a normal distribution


# Compute the 99.5% ES of a normal distribution
編輯並執行程式碼