aboutsummaryrefslogtreecommitdiffstats
path: root/R/load_cf.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/load_cf.R')
-rw-r--r--R/load_cf.R19
1 files changed, 12 insertions, 7 deletions
diff --git a/R/load_cf.R b/R/load_cf.R
index 6d43a951..5a4882b1 100644
--- a/R/load_cf.R
+++ b/R/load_cf.R
@@ -74,6 +74,16 @@ processzipfiles <- function(workdate=Sys.Date()){
return(list(dealnames=dealnames.hash, cusips=cusips.hash, zipfiles=zipfiles))
}
+getconfig <- function(dealname, workdate){
+ configfile <- file.path(root.dir, "Scenarios", paste("Intex curves", workdate, sep="_"),
+ "csv", paste0(dealname, ".config"))
+ if(file.exists(configfile)){
+ return(yaml.load_file(configfile))
+ }else{
+ return(list(reinvflag=TRUE))
+ }
+}
+
getdealcf <- function(params, workdate=Sys.Date()){
cfdata <- list()
fields <- c("Cashflow", "Principal", "Interest")
@@ -91,6 +101,7 @@ getdealcf <- function(params, workdate=Sys.Date()){
## we also add some wiggle room at the end to make sure we're not missing one date
prevpaydate <- basic.advance(sqldata$"Deal Next Pay Date", -6, "month")
alldates <- seq.Date(from=prevpaydate, sqldata$maturity+11, by="1 month")
+ config <- getconfig(dealname, workdate)
T <- ifelse(alldates>=L3m$params$tradeDate, yearFrac(L3m$params$tradeDate, alldates), 0)
DC <- DiscountCurve(L3m$params, L3m$tsQuotes, T)
@@ -98,13 +109,7 @@ getdealcf <- function(params, workdate=Sys.Date()){
Discounts=DC$discounts,
T=T, key="Date")
cfdata[[dealname]] <- list(mv = mv, currbal = sqldata$"Curr Collat Bal")
- configfile <- file.path(root.dir, "Scenarios", paste("Intex curves", workdate, sep="_"),
- "csv", paste0(dealname, ".config"))
- if(file.exists(configfile)){
- config <- yaml.load_file(configfile)
- }else{
- config <- list(reinvflag=TRUE)
- }
+
if(is.na(sqldata$"Reinv End Date")||!config$reinvflag){
tranches <- "COLLAT"
}else{