In [ 85 ]: S0_CVA = np.exp(-r * T) * 1 / I * np.sum(( 1 - L * D) * ST)
S0_CVA
Out[85]: 99.466624103426781
This should be (roughly) the same as subtracting the CVaR value from the current asset
value:
In [ 86 ]: S0_adj = S0 - CVaR
S0_adj
Out[86]: 99.48479888658386
In this particular simulation example, we observe roughly 1,000 losses due to credit risk,
which is to be expected given the assumed default probability of 1% and 100,000
simulated paths:
In [ 87 ]: np.count_nonzero(L * D * ST)
Out[87]: 1031
Figure 10-21 shows the complete frequency distribution of the losses due to a default. Of
course, in the large majority of cases (i.e., in about 99,000 of the 100,000 cases) there is
no loss to observe:
In [ 88 ]: plt.hist(L * D * ST, bins= 50 )
plt.xlabel(‘loss’)
plt.ylabel(‘frequency’)
plt.grid(True)
plt.ylim(ymax= 175 )
Figure 10-21. Losses due to risk-neutrally expected default (stock)
Consider now the case of a European call option. Its value is about 10.4 currency units at a
strike of 100:
In [ 89 ]: K = 100.
hT = np.maximum(ST - K, 0 )
C0 = np.exp(-r * T) * 1 / I * np.sum(hT)
C0
Out[89]: 10.427336109660052
The CVaR is about 5 cents given the same assumptions with regard to probability of
default and loss level:
In [ 90 ]: CVaR = np.exp(-r * T) * 1 / I * np.sum(L * D * hT)
CVaR
Out[90]: 0.053822578452208093
Accordingly, the adjusted option value is roughly 5 cents lower:
In [ 91 ]: C0_CVA = np.exp(-r * T) * 1 / I * np.sum(( 1 - L * D) * hT)
C0_CVA