From 290e3cc11ee6d529c7f862ec46861f4ac95254e7 Mon Sep 17 00:00:00 2001 From: Guillaume Horel Date: Mon, 23 Jun 2014 10:49:46 -0400 Subject: add a flag to compute undiscounted expected loss --- R/tranche_functions.R | 10 +++++++--- 1 file 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){ -- cgit v1.2.3-70-g09d2