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.R10
1 files changed, 6 insertions, 4 deletions
diff --git a/R/load_cf.R b/R/load_cf.R
index f3b41010..215e353f 100644
--- a/R/load_cf.R
+++ b/R/load_cf.R
@@ -248,16 +248,17 @@ getcusipcf <- function(cusips, cfdata, dist, workdate=Sys.Date()){
cusipdata[[cusip]]$delta <-
compute.delta(dist, cfdata[[dealnames[i]]]$weight,
cusipdata[[cusip]]$fields[,"Cashflow"]/cusipdata[[cusip]]$currbal,
- workdate)
+ prevBusDay(workdate))
}
}
return(cusipdata)
}
-compute.delta <- function(indexdist, dealweight, cusip.pv, workdate=Sys.Date()){
+compute.delta <- function(indexdist, dealweight, cusip.pv, workdate=prevBusDay(Sys.Date())){
indexpv <- c()
- cs <- couponSchedule(nextIMMDate(workdate), as.Date("2017-12-20"), "Q", "FLOAT", 0, 0.05)
+ cs <- couponSchedule(nextIMMDate(workdate), as.Date("2017-12-20"), "Q",
+ "FLOAT", 0, 0.05,workdate)
nT <- dim(indexdist$L)[2]
Ngrid <- dim(indexdist$L)[1]
scenariosl <- matrix(0, length(dealweight), nT)
@@ -277,6 +278,7 @@ compute.delta <- function(indexdist, dealweight, cusip.pv, workdate=Sys.Date()){
cfdata <- getdealcf(dealnames, workdate)
availablecusips <- cusips[dealnamefromcusip(cusips) %in% names(cfdata)]
+## load dist into the namespace
load(file.path(root.dir, "Scenarios", "Calibration", sprintf("marketdata-%s.RData", calibration.date)))
cusipdata <- getcusipcf(availablecusips, cfdata, dist, workdate)
save.dir <- file.path(root.dir, "Scenarios", paste0("Prices_", workdate))
@@ -286,7 +288,7 @@ save(cusipdata, cfdata, file=file.path(save.dir, "cashflows.RData"),
## upload wapbasis
for(dealname in names(cfdata)){
sqlstring <- sprintf(paste0("UPDATE et_deal_model_numbers SET ",
- "wapbasis = '%s' WHERE dealname= '%s' AND updatedate = '%s'"),
+ "wapbasis = '%s' WHERE dealname= '%s' AND updatedate = '%s'"),
cfdata[[dealname]]$wapbasis*100,
dealname,
strftime(workdate))