diff options
Diffstat (limited to 'R/cds_functions_generic.R')
| -rw-r--r-- | R/cds_functions_generic.R | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index b343dcde..3e76259c 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -624,18 +624,18 @@ indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE, ## (Say we compute the 3 year pv based on 5 year curves ## forward.tweak only makes sense if epsilon is non zero ## and will teak the curves starting from forward.index - if(epsilon != 0) { - portfolio <- tweakportfolio(index$portfolio, epsilon, start.tweak, end.tweak) - }else { - portfolio <- index$portfolio - } + portfolio <- + if(epsilon != 0) { + tweakportfolio(index$portfolio, epsilon, start.tweak, end.tweak) + } else { + index$portfolio + } startdate <- tradedate + 1 cs <- index$cs[index$cs$unadj.dates <= maturity,] cl.list <- vapply(portfolio, function(x) { cl <- couponleg(cs, x@curve, startdate) if(is.na(cl)) { logerror(paste("couldn't compute single name coupon leg for", x@issuer)) - return( NA ) } return( cl ) }, numeric(1)) @@ -643,7 +643,6 @@ indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE, pl <- defaultleg(cs, x@curve, x@recovery, startdate) if(is.na(pl)) { logerror(paste("couldn't compute single name protection leg for", x@issuer)) - return( NA ) } return( pl ) }, numeric(1)) |
