summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2014-06-30 17:51:44 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2014-06-30 17:51:44 -0400
commit089f7bf1089b1825b94206b68d8138f4a529f30b (patch)
tree8f4ad559307f724d4e51882733aee66e89b6065d
parent6b572b022895a93f8bd648b0f25d45ac419ea616 (diff)
downloadlossdistrib-089f7bf1089b1825b94206b68d8138f4a529f30b.tar.gz
add function to compute theta
-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