aboutsummaryrefslogtreecommitdiffstats
path: root/R/tranche_functions.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/tranche_functions.R')
-rw-r--r--R/tranche_functions.R10
1 files changed, 6 insertions, 4 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R
index b33ec339..41d55295 100644
--- a/R/tranche_functions.R
+++ b/R/tranche_functions.R
@@ -214,7 +214,7 @@ adjust.skew <- function(index1, index2, method=c("ATM", "TLP", "PM")) {
pmax(pmin(x, 0.99), 0.01)
}
- if(method=="ATM") {
+ if(method == "ATM") {
K1eq <- el1/el2 * K2
} else if(method == "TLP") {
K1eq <- c()
@@ -280,6 +280,8 @@ BCtranche.delta <- function(index, complement=FALSE) {
deltas <- (bp[,2]-bp[,3])/(indexbp[2]-indexbp[3])*tranche.factor(index)/index$factor
deltasplus <- (bp[,4]-bp[,1])/(indexbp[4]-indexbp[1])*tranche.factor(index)/index$factor
+ print(deltas)
+ print(deltasplus)
gammas <- (deltasplus-deltas)/(indexbp[2]-indexbp[1])/100
return( data.frame(delta=deltas, gamma=gammas) )
@@ -354,10 +356,10 @@ EL <- function(index, discounted=TRUE, shortened=0) {
df <- index$cs$df[1:(Ncol-shortened)]
}
ELvec <- as.numeric(crossprod(index$issuerweights * (1-index$recov), DP))
- if(!discounted){
+ if(!discounted) {
return( ELvec[length(ELvec)] )
- }else{
- return( sum(df*diff(c(0, ELvec))) )
+ } else {
+ return( sum(df*diff(c(0, ELvec))) )
}
}