diff options
Diffstat (limited to 'R/tranche_functions.R')
| -rw-r--r-- | R/tranche_functions.R | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/R/tranche_functions.R b/R/tranche_functions.R index eb652b8..16960e0 100644 --- a/R/tranche_functions.R +++ b/R/tranche_functions.R @@ -729,24 +729,18 @@ BCtranche.delta <- function(index, tradedate = Sys.Date()){ return(newindex)
}
})
- dPVindex <- indexpv(index.list[[2]], tradedate = tradedate, clean = FALSE)$bp -
- indexpv(index.list[[3]], tradedate = tradedate, clean = FALSE)$bp
- dPVindex2 <- indexpv(index.list[[4]], tradedate = tradedate, clean = FALSE)$bp -
- indexpv(index, tradedate = tradedate, clean = FALSE)$bp
- dPVindex1 <- indexpv(index.list[[2]], tradedate = tradedate, clean = FALSE)$bp-
- indexpv(index, tradedate = tradedate, clean = FALSE)$bp
- bp <- matrix(0, length(index$K)-1, 4)
+ bp <- matrix(0, length(index$K)-1, length(index.list))
+ indexbp <- rep(0, length(index.list))
for(j in seq_along(index.list)){
temp <- BCtranche.pv(index.list[[j]])
+ indexbp[j] <- indexpv(index.list[[j]], tradedate = tradedate, clean = FALSE)$bp
bp[,j] <- temp$bp
}
- dPVtranche <- bp[,2]-bp[,3]
- dPVtranche2 <- bp[,4] - bp[,1]
- deltas <- dPVtranche/dPVindex
- deltasplus <- dPVtranche2/dPVindex2
- gammas <- (deltasplus-deltas)/dPVindex1/100
+ deltas <- (bp[,2]-bp[,3])/(indexbp[2]-indexbp[3])
+ deltasplus <- (bp[,4]-bp[,1])/(indexbp[4]-indexbp[1])
+ gammas <- (deltasplus-deltas)/(indexbp[1]-indexbp[1])/100
return( list(deltas=deltas, gammas=gammas) )
}
|
