शुरू करेंमुफ़्त में शुरू करें

VaR और जोखिम एक्सपोज़र

पहले आपने उस स्थिति में VaR और CVaR निकाले थे जब हानियाँ Normally distributed थीं. यहाँ आप scipy.stats में उपलब्ध एक और सामान्य loss distribution, Student's t-distribution (या T) का उपयोग करके VaR निकालेंगे.

आप T distribution से (30 - 1 = 29 degrees of freedom के साथ) 99% VaR मापों का एक array निकालेंगे, जिसके लिए investment bank पोर्टफोलियो losses पर 30-दिन की rolling windows ली जाएँगी.

सबसे पहले आप हर window का mean और standard deviation निकालेंगे और उन्हें rolling_parameters की एक list में रखेंगे. इन्हीं से आप 99% VaR मापों का array निकालेंगे.

फिर आप इस array का उपयोग करके उस पोर्टफोलियो का जोखिम एक्सपोज़र प्लॉट करेंगे जिसकी शुरुआती कीमत $100,000 है. याद रखिए, जोखिम एक्सपोज़र = हानि की प्रायिकता (यह 1% है) × हानि की राशि (यह 99% VaR द्वारा दी गई हानि है).

यह अभ्यास पाठ्यक्रम का हिस्सा है

Python में Quantitative Risk Management

पाठ्यक्रम देखें

अभ्यास निर्देश

  • scipy.stats से Student's t-distribution इम्पोर्ट करें.
  • losses से 30-दिन की window का mean mu और standard deviation sigma वेक्टर निकालें, और उन्हें rolling_parameters में रखें.
  • rolling_parameters के एलिमेंट्स से बनी T distributions की list पर t.ppf() का उपयोग करके 99% VaR मापों का Numpy array VaR_99 निकालें.
  • VaR_99 array से जुड़े जोखिम एक्सपोज़र की गणना करें और उसे visualize करें.

इंटरैक्टिव व्यावहारिक अभ्यास

इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।

# Import the Student's t-distribution
from scipy.____ import t

# Create rolling window parameter list
mu = losses.rolling(30).____
sigma = losses.rolling(30).____
rolling_parameters = [(29, mu[i], s) for i,s in enumerate(sigma)]

# Compute the 99% VaR array using the rolling window parameters
VaR_99 = np.array( [ t.ppf(____, *params) 
                    for params in ____ ] )

# Plot the minimum risk exposure over the 2005-2010 time period
plt.plot(losses.index, 0.01 * ____ * 100000)
plt.show()
कोड संपादित करें और चलाएँ