diff options
Diffstat (limited to 'R/intex_deal_functions.R')
| -rw-r--r-- | R/intex_deal_functions.R | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R index a1e4626b..1717a336 100644 --- a/R/intex_deal_functions.R +++ b/R/intex_deal_functions.R @@ -391,15 +391,20 @@ getdealschedule <- function(dealdata, freq = c("Monthly", "Quarterly"), tradedat } intexportfolio.forwardprice <- function(cdrmonthly, recoverymonthly, startdate, maturity, - coupontype, margin, liborfloor){ - if(missing(liborfloor)||is.na(liborfloor)){ - currentcoupon <- margin - }else{ - currentcoupon <- margin + liborfloor - } - forwardcs <- data.table(couponSchedule(nextpaydate=startdate+45, maturity, - frequency="Q", coupontype, margin, - currentcoupon, tradedate=startdate), key="dates") + coupontype, margin, liborfloor) { + forwardcs <- + if( missing(liborfloor) || is.na(liborfloor) ) { + data.table(couponSchedule(nextpaydate=startdate+45, maturity, + frequency="Q", coupontype, margin, + 0., tradedate=startdate), + key="dates") + } else { + data.table(couponSchedule(nextpaydate=startdate+45, maturity, + frequency="Q", coupontype, margin, + NA, tradedate=startdate, liborfloor=liborfloor), + key="dates") + } + notionals <- cdrmonthly[date>=startdate, lapply(.SD,function(x)cumprod(1-x/100*1/12)), .SDcols=paste0("V",1:100)] recovery <- as.matrix(recoverymonthly[date>=startdate, .SD, .SDcols=paste0("V",1:100)])* @@ -420,7 +425,7 @@ intexportfolio.forwardprice <- function(cdrmonthly, recoverymonthly, startdate, mean(recovery+po+io) } -compute.reinvprices <- function(dealname, cdrmonthly, recoverymonthly, params, rollingmaturity, tradedate){ +compute.reinvprices <- function(dealname, cdrmonthly, recoverymonthly, params, rollingmaturity, tradedate) { reinvassets <- get.reinvassets(dealname, tradedate) reinvprices <- list() if(length(reinvassets) > 0) { |
