diff options
Diffstat (limited to 'R/cds_functions.R')
| -rw-r--r-- | R/cds_functions.R | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/R/cds_functions.R b/R/cds_functions.R index 708c1262..09e5354b 100644 --- a/R/cds_functions.R +++ b/R/cds_functions.R @@ -303,17 +303,18 @@ bonddp <- function(collateral, R=0.7){ }
tweakportfolio <- function(portfolio, epsilon, multiplicative=TRUE){
- ## tweak the curves of a portfolio
+ ## tweak a portfolio of creditcurves
## if multiplicative is TRUE apply a multiplicative tweak
- ## otherwise apply an additive on
+ ## otherwise apply an additive one
if(multiplicative){
r <- lapply(portfolio, function(x) {
x@curve@hazardrates <- x@curve@hazardrates * (1+epsilon)
x
})
}else{
+ ## we do a tweak to the spread
r <- lapply(portfolio, function(x) {
- x@curve@hazardrates <- x@curve@hazardrates + epsilon
+ x@curve@hazardrates <- x@curve@hazardrates + epsilon/(1-x@recovery)
x
})
}
|
