aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/load_cf.R21
1 files changed, 13 insertions, 8 deletions
diff --git a/R/load_cf.R b/R/load_cf.R
index 8ab40654..a6810e0d 100644
--- a/R/load_cf.R
+++ b/R/load_cf.R
@@ -40,14 +40,19 @@ sanitize.column <- function(vec){
return( as.numeric(vec) )
}
-allfiles <- list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*.txt")
-allfiles <- unique(sapply(strsplit(allfiles, "-"), function(x) x[1]))
-allfiles <- allfiles[!(allfiles=="Total")]
-dealnames <- list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*COLLAT_INITIAL-CF-Scen100")
-dealnames <- c(dealnames, list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*COLLAT-CF-Scen100"))
-dealnames <- unique(sapply(strsplit(dealnames, "-"), function(x) x[1]))
-cusips <- setdiff(allfiles, dealnames)
-dealnames <- tolower(dealnames)
+if(length(args)>=2){
+ cusips <- args[-1]
+ dealnames <- unique(dealnamefromcusip(cusips))
+}else{
+ allfiles <- list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*.txt")
+ allfiles <- unique(sapply(strsplit(allfiles, "-"), function(x) x[1]))
+ allfiles <- allfiles[!(allfiles=="Total")]
+ dealnames <- list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*COLLAT_INITIAL-CF-Scen100")
+ dealnames <- c(dealnames, list.files(file.path(root.dir, "Scenarios", paste0("Prices_", workdate)), "*COLLAT-CF-Scen100"))
+ dealnames <- unique(sapply(strsplit(dealnames, "-"), function(x) x[1]))
+ cusips <- setdiff(allfiles, dealnames)
+ dealnames <- tolower(dealnames)
+}
getdealcf <- function(dealnames, workdate=Sys.Date()){
cfdata <- list()