Credit Value Adjustment
Alluve MarketSimulator allows to perform credit value adjustment on one or more portfolios.
Credit value adjustment (CVA) is the difference between the risk-free value of a portfolio and its value that accounts for possible losses due to the counterparty's default. CVA is calculated as the risk-neutral expectation of our losses, discounted to today.
Let

be our exposure to the counterparty at time

,

be the recovery rate (the part of the exposure that we will be able to recover in case of default),

be the probability that the counterparty defaults between

and

, and

the price of at time

of a zero-coupon bond that pays 1 at

. In addition, let us assume that

is independent from the credit rating of the counterparty. Then our unilateral credit value adjustment is

To avoid integrating to infinity, note that if

is the maturity of the longest transaction in the portfolio,

; thus we only have to integrate from 0 to

.
Although MarketSimulator does not calculate CVA directly, it will do the hardest part: the expected exposure calculation.
Suppose our expected exposure profile looks like the one below:
and we know the counterparty's recovery rate

and probability of default in one year

(those values can be obtained, for example, from CDS spreads).
The probability that the counterparty default happens between n and n+1 years from now is
To be conservative, we take the maximum expected exposure

for each year:

and discount it from the beginning of the year to today (that corresponds to the worst case scenario where the default happens at the beginning of the year).
The credit value adjustment is
References
Zhu, Steven H. and Pykhtin, Michael, A Guide to Modeling Counterparty Credit Risk. GARP Risk Review, July/August 2007. Available at SSRN:
http://ssrn.com/abstract=1032522