aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/tranche_functions.R14
1 files changed, 13 insertions, 1 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 7c646f86..7679b076 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -325,11 +325,23 @@ MFtranche.delta <- function(index){
BCtranche.corr01 <- function(index, eps=0.01, complement=FALSE){
##does a parallel shift of the skew and computes the change in pv
before <- BCtranche.pv(index, complement=complement)
- index$rho[-1] <- index$rho[-1]+eps
+ index$rho[-1] <- exp(log(index$rho[-1])*(1+eps))
after <- BCtranche.pv(index, complement=complement)
return(after$bp-before$bp)
}
+BCtranche.VaR <- function(index, skew.shocks, complement=FALSE){
+ before <- BCtranche.pv(index, complement=complement)
+ n <- length(index$rho)
+ r <- matrix(0, nrow(skew.shocks))
+ logskew <- log(index$skew[-c(1,n)])
+ for(i in 1:nrow(skew.shocks)){
+ index$rho[-c(1,n)] <- exp(logskew*(1+skew.shocks[i,]))
+ after <- BCtranche.pv(index, complement=complement)
+ r[i,] <- before-after
+ }
+}
+
EL <- function(index, discounted=TRUE, shortened=0){
## computes the expected loss of a portfolio (time discounted if discounted is TRUE)
## given the default curves and recovery