summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2014-06-23 10:49:46 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2014-06-23 10:49:46 -0400
commit290e3cc11ee6d529c7f862ec46861f4ac95254e7 (patch)
tree0755d600248771265253bef833447a6bd41803cf
parent5d70571e21b0f918d6dcc33ceb1379b72336e07c (diff)
downloadlossdistrib-290e3cc11ee6d529c7f862ec46861f4ac95254e7.tar.gz
add a flag to compute undiscounted expected loss
-rw-r--r--R/tranche_functions.R10
1 files changed, 7 insertions, 3 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index d071fda..ce08288 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -747,13 +747,17 @@ BCtranche.delta <- function(index, Z, w, N=length(index$portolio)+1, tradedate =
return( list(deltas=deltas, gammas=gammas) )
}
-EL <- function(index){
- ## computes the expected loss of a portfolio (time discounted)
+EL <- function(index, discounted=TRUE){
+ ## computes the expected loss of a portfolio (time discounted if discounted is TRUE)
## given the default curves and recovery
## should be very close to the protection leg of the portfolio of cds
## index should be a list with issuerweights, recov, defaultprob and cs parameters
ELvec <- as.numeric(crossprod(index$issuerweights * (1-index$recov), index$defaultprob))
- return( sum(index$cs$df*diff(c(0, ELvec))) )
+ if(!discounted){
+ return( diff(c(0, ELvec)) )
+ }else{
+ return( sum(index$cs$df*diff(c(0, ELvec))) )
+ }
}
ELtrunc <- function(index, K, rho, Z, w, Ngrid){