diff options
Diffstat (limited to 'R/load_cf.R')
| -rw-r--r-- | R/load_cf.R | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/R/load_cf.R b/R/load_cf.R index b312bf4c..ebd8956b 100644 --- a/R/load_cf.R +++ b/R/load_cf.R @@ -31,7 +31,7 @@ L3m <- buildMarkitYC(MarkitData) L6m <- buildMarkitYC(MarkitData, dt = 1/2)
L12m <- buildMarkitYC(MarkitData, dt = 1)
setEvaluationDate(as.Date(MarkitData$effectiveasof))
-
+dm <- 0
sanitize.column <- function(vec){
vec <- gsub(",", "", vec)
index <- grep("\\(", vec)
@@ -120,7 +120,8 @@ getdealcf <- function(dealnames, workdate=Sys.Date()){ if(length(futuredates) == 0){
df <- rep(1, length(pastdates))
}else{
- df <- c(rep(1, length(pastdates)), DC$discounts[1:length(futuredates)])
+ df.dm <- exp(-dm*yearFrac(L3m$params$tradeDate, futuredates))
+ df <- c(rep(1, length(pastdates)), df.dm*DC$discounts[1:length(futuredates)])
}
if(nrow(data)>0){
pv <- c(pv, crossprod(df, data[,field]))
@@ -196,13 +197,14 @@ getcusipcf <- function(cusips, cfdata, dist, workdate=Sys.Date()){ }
futuredates <- data$Date[data$Date >= L3m$params$tradeDate]
pastdates <- data$Date[data$Date < L3m$params$tradeDate]
+ T <- yearFrac(L3m$params$tradeDate, futuredates)
if(i==1||length(futuredates)>length(DC$times)){
- DC <- DiscountCurve(L3m$params, L3m$tsQuotes, yearFrac(L3m$params$tradeDate, futuredates))
+ DC <- DiscountCurve(L3m$params, L3m$tsQuotes, T)
}
if(length(futuredates) == 0){
df <- rep(1, length(pastdates))
}else{
- df <- c(rep(1, length(pastdates)), DC$discounts[1:length(futuredates)])
+ df <- c(rep(1, length(pastdates)), DC$discounts[1:length(futuredates)]*exp(-dm*T))
}
pv <- c()
for(field in fields){
|
