diff options
| -rw-r--r-- | R/cds_functions_generic.R | 13 | ||||
| -rw-r--r-- | R/thetas-curve.R | 2 |
2 files changed, 7 insertions, 8 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)) diff --git a/R/thetas-curve.R b/R/thetas-curve.R index 0d3baf2b..7825b362 100644 --- a/R/thetas-curve.R +++ b/R/thetas-curve.R @@ -61,7 +61,7 @@ for(i in seq_along(unique.dates)) { next } index <- set.singlenamesdata(index, tradedate) - if(is.null(index$portfolio)){ + if(is.null(index$portfolio)) { next } index$cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), |
