summaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/tranche_functions.R16
1 files changed, 13 insertions, 3 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index 469d68f..eb652b8 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -694,12 +694,22 @@ BCtranche.pv <- function(index, protection=FALSE){
theta.adjust.skew <- function(index, shortened=4){
#ajust the correlation skew by doing ATM mapping on the expected loss
el <- EL(index)
- elshort <- EL(index, shortened)
+ elshort <- EL(index, shortened=shortened)
K <- index$K[-c(1,length(index$K))]
rhofun <- splinefun(K, index$rho[-c(1, length(index$rho))], "natural")
K <- el/elshort*K
- return(c(0, rhofun(K)))
- }
+ return(c(0, rhofun(K), NA))
+}
+
+BCtranche.theta <- function(index, shortened=4){
+ temp <- BCtranche.pv(index)
+ index$rho <- theta.adjust.skew(index, shortened)
+ N <- nrow(index$cs)-shortened
+ index$cs <- index$cs[1:N,]
+ index$defaultprob <- index$defaultprob[,1:N]
+ temp2 <- BCtranche.pv(index)
+ return(temp2$bp-temp$bp+index$tranche.running)
+}
BCtranche.delta <- function(index, tradedate = Sys.Date()){
## computes the tranche delta (on current notional) by doing a proportional