aboutsummaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/cds_functions_generic.R3
-rw-r--r--R/cds_utils.R4
2 files changed, 4 insertions, 3 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R
index 3ea19b14..fc8b303a 100644
--- a/R/cds_functions_generic.R
+++ b/R/cds_functions_generic.R
@@ -551,7 +551,8 @@ indexpv <- function(index, epsilon=0, tradedate=Sys.Date(), clean=TRUE,
portfolio <- index$portfolio
}
startdate <- tradedate + 1
- cs <- index$cs[index$cs$dates<=maturity,]
+ #ugly hack
+ cs <- index$cs[index$cs$dates-maturity< 3,]
cl.list <- unlist(lapply(portfolio, function(x){couponleg(cs, x@curve, startdate)}))
pl.list <- unlist(lapply(portfolio, function(x){defaultleg(cs, x@curve, x@recovery, startdate)}))
spread <- index$quotes$spread[index$quotes$maturity==maturity]
diff --git a/R/cds_utils.R b/R/cds_utils.R
index 2d83457d..09e07960 100644
--- a/R/cds_utils.R
+++ b/R/cds_utils.R
@@ -74,6 +74,8 @@ couponSchedule <- function(nextpaydate=NULL, maturity, frequency, coupontype, cu
dates <- seq(nextpaydate, as.Date(as.POSIXlt(maturity)), by = bystring)
}
}
+ dates <- dates[ dates >= tradedate]
+ dates <- adjust(calendar="UnitedStates/GovernmentBond", dates)
if(length(dates)==0){
dates <- maturity
}else{
@@ -81,8 +83,6 @@ couponSchedule <- function(nextpaydate=NULL, maturity, frequency, coupontype, cu
dates <- c(dates, maturity)
}
}
- dates <- dates[ dates >= tradedate]
- dates <- adjust(calendar="UnitedStates/GovernmentBond", dates)
names(dates) <- NULL
DC <- switch(frequency,
S = DiscountCurve(L6m$params, L6m$tsQuotes, yearFrac(L6m$params$tradeDate, dates)),