diff options
Diffstat (limited to 'R/load_cf.R')
| -rw-r--r-- | R/load_cf.R | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/R/load_cf.R b/R/load_cf.R index 6805327e..5cb404ea 100644 --- a/R/load_cf.R +++ b/R/load_cf.R @@ -170,16 +170,17 @@ getdealcf <- function(dealnames, workdate=Sys.Date()){ flag <- FALSE
n.scenarios <- 100
for(dealname in dealnames){
- r <- matrix(0, n.scenarios, 3)
- colnames(r) <- fields
sqlstring <- sprintf("select marketvalue from latest_deal_model_numbers where dealname='%s'", dealname)
mv <- dbGetQuery(dbCon, sqlstring)$marketvalue
sqlstring <- sprintf(paste0("select \"Curr Collat Bal\", \"Reinv End Date\", ",
"\"Deal Next Pay Date\" , maturity from ",
"historical_clo_universe('%s', '%s')"), dealname, workdate)
sqldata <- dbGetQuery(dbCon, sqlstring)
+ ## to get the list of payment dates, we backtrack a little bit, because sometimes the first
+ ## date in intex vector is pre current 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", -3, "month")
- alldates <- seq.Date(from=prevpaydate, sqldata$maturity, by="1 month")
+ alldates <- seq.Date(from=prevpaydate, sqldata$maturity+5, by="1 month")
T <- ifelse(alldates>=L3m$params$tradeDate, yearFrac(L3m$params$tradeDate, alldates), 0)
DC <- DiscountCurve(L3m$params, L3m$tsQuotes, T)
@@ -199,6 +200,8 @@ getdealcf <- function(dealnames, workdate=Sys.Date()){ }
}
for(tranche in tranches){
+ r <- matrix(0, n.scenarios, 3)
+ colnames(r) <- fields
for(i in 1:n.scenarios){
filename <- paste0(paste(toupper(dealname), tranche, "CF", paste0("Scen", i), sep="-"), ".txt")
## we catch the error if there is an error reading the file
|
