aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/cds_utils.R14
-rw-r--r--R/intex_deal_functions.R18
2 files changed, 22 insertions, 10 deletions
diff --git a/R/cds_utils.R b/R/cds_utils.R
index cdccbb78..d5ecaa4d 100644
--- a/R/cds_utils.R
+++ b/R/cds_utils.R
@@ -90,11 +90,15 @@ couponSchedule <- function(nextpaydate=NULL, maturity,
if(coupontype == "FLOAT" && !is.na(margin)) {
## if is.na(margin) probably letter of credit
## we floor the coupon at the current gross rate
- if( missing(liborfloor) ) {
- coupons <- pmax(currentcoupon, forwards + margin)
- } else {
- coupons <- pmax(forwards, liborfloor) + margin
- }
+ coupons <- if( missing(liborfloor) ) {
+ if( is.na(currentcoupon) ) {
+ forwards + margin
+ } else {
+ pmax(currentcoupon, forwards + margin)
+ }
+ } else {
+ pmax(forwards, liborfloor) + margin
+ }
} else {
coupons <- rep(currentcoupon, length(dates))
}
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R
index 1717a336..53f12c77 100644
--- a/R/intex_deal_functions.R
+++ b/R/intex_deal_functions.R
@@ -395,16 +395,15 @@ intexportfolio.forwardprice <- function(cdrmonthly, recoverymonthly, startdate,
forwardcs <-
if( missing(liborfloor) || is.na(liborfloor) ) {
data.table(couponSchedule(nextpaydate=startdate+45, maturity,
- frequency="Q", coupontype, margin,
- 0., tradedate=startdate),
+ frequency="Q", coupontype, NA,
+ margin, tradedate=startdate),
key="dates")
} else {
data.table(couponSchedule(nextpaydate=startdate+45, maturity,
- frequency="Q", coupontype, margin,
- NA, tradedate=startdate, liborfloor=liborfloor),
+ frequency="Q", coupontype, NA,
+ margin, 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)])*
@@ -433,6 +432,15 @@ compute.reinvprices <- function(dealname, cdrmonthly, recoverymonthly, params, r
for(assetname in names(reinvassets)){
asset <- reinvassets[[assetname]]
coupon <- if(asset$coupontype=="FLOAT") params$reinvfloat else params$reinvfixed
+ ## reinvprices[[assetname]] <- c()
+ ## for(i in seq_along(cdrmonthly$date)) {
+ ## date <- cdrmonthly$date[i]
+ ## reinvprices[[assetname]] <-
+ ## c(reinvprices[[assetname]],
+ ## 100 * intexportfolio.forwardprice(cdrmonthly, recoverymonthly, date,
+ ## min(date+rollingmaturity, maturity),
+ ## asset$coupontype, coupon, asset$liborfloor/100))
+ ## }
reinvprices[[assetname]] <- foreach(date = iter(cdrmonthly$date), .combine=c) %dopar% {
100 * intexportfolio.forwardprice(cdrmonthly, recoverymonthly, date,
min(date+rollingmaturity, maturity),