diff options
| -rw-r--r-- | R/calibrate_tranches_BC.R | 51 |
1 files changed, 26 insertions, 25 deletions
diff --git a/R/calibrate_tranches_BC.R b/R/calibrate_tranches_BC.R index 9e51e480..8687a1f9 100644 --- a/R/calibrate_tranches_BC.R +++ b/R/calibrate_tranches_BC.R @@ -8,32 +8,33 @@ library(logging) basicConfig()
removeHandler('basic.stdout')
addHandler(writeToFile, file=file.path(root.dir, "logs", "calibrate_tranches_BC.log"))
-library(optparse)
-option_list <- list(
- make_option(c("-u", "--update"), action="store_true", default=FALSE,
- help="Update from the last run date [default %default]"),
- make_option(c("-c", "--config"), metavar="config_file",
- help="Runs the list of indices provided in CONFIG_FILE"),
- make_option(c("-i", "--index"), help="Index name we want to run"),
- make_option("--tenor", default="5yr", help="Tenor we want to run [default %default]"),
- make_option("--until", default=Sys.Date()-1, type="character",
- help="last date to run [default %default]"))
-
-args <- parse_args(OptionParser(option_list=option_list))
-## default values
-if(is.null(args$config)){
- if(is.null(args$index)){
- stop("Please provide an index name")
+if(!interactive()){
+ library(optparse)
+ option_list <- list(
+ make_option(c("-u", "--update"), action="store_true", default=FALSE,
+ help="Update from the last run date [default %default]"),
+ make_option(c("-c", "--config"), metavar="config_file",
+ help="Runs the list of indices provided in CONFIG_FILE"),
+ make_option(c("-i", "--index"), help="Index name we want to run"),
+ make_option("--tenor", default="5yr", help="Tenor we want to run [default %default]"),
+ make_option("--until", default=Sys.Date()-1, type="character",
+ help="last date to run [default %default]"))
+ args <- parse_args(OptionParser(option_list=option_list))
+ ## default values
+ if(is.null(args$config)){
+ if(is.null(args$index)){
+ stop("Please provide an index name")
+ }
+ config <- list(runs=list(c(args$index, args$tenor)))
+ }else{
+ config <- yaml::yaml.load_file(file.path(root.dir,"code", "etc", args$config))
}
- config <- list(runs=list(c(args$index, args$tenor)))
-}else{
- config <- yaml::yaml.load_file(file.path(root.dir,"code", "etc", args$config))
-}
-
-if(interactive()){
- args <- list(config=yaml::yaml.load_file(file.path(root.dir,"code", "etc", "runs.yml")),
- until = Sys.Date()-1,
- update = TRUE)
+} else {
+ ## args <- list(config=yaml::yaml.load_file(file.path(root.dir,"code", "etc", "runs.yml")),
+ ## until = Sys.Date()-1,
+ ## update = TRUE)
+ args <- list(update=TRUE, until = Sys.Date()-1)
+ config <- list(runs=list(c("hy25", "5yr")))
options(error=recover)
}
|
