diff options
| -rw-r--r-- | R/build_scenarios.R | 10 | ||||
| -rw-r--r-- | R/cds_utils.R | 8 |
2 files changed, 3 insertions, 15 deletions
diff --git a/R/build_scenarios.R b/R/build_scenarios.R index dd7d1b0a..41670c80 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -26,15 +26,7 @@ source(file.path(root.dir, "code", "R", "intex_deal_functions.R")) source(file.path(root.dir, "code", "R", "index_definitions.R"))
source(file.path(root.dir, "code", "R", "etdb.R"))
source(file.path(root.dir, "code", "R", "cds_functions_generic.R"))
-
-prevBusDay <- function(workdate = Sys.Date()){
- i <- 1
- while(!isBusinessDay(calendar = "UnitedStates/GovernmentBond",
- workdate - i)){
- i <- i+1
- }
- return( workdate - i )
-}
+source(file.path(root.dir, "code", "R", "cds_utils.R"))
get.reinvassets <- function(dealname, workdate){
r <- vector("list", 2)
diff --git a/R/cds_utils.R b/R/cds_utils.R index a5e7648d..11a7032c 100644 --- a/R/cds_utils.R +++ b/R/cds_utils.R @@ -5,12 +5,7 @@ today <- function() { }
prevBusDay <- function(workdate = Sys.Date()){
- i <- 1
- while(!isBusinessDay(calendar = "UnitedStates/GovernmentBond",
- workdate - i)){
- i <- i+1
- }
- return( workdate - i )
+ advance(calendar = "UnitedStates/GovernmentBond", n=-1, timeUnit=0)
}
convertTenor <- function(tenor) {
@@ -111,6 +106,7 @@ couponSchedule <- function(nextpaydate=NULL, maturity, frequency, coupontype, cu }
}
dates <- dates[ dates >= startdate]
+ dates <- adjust(calendar="UnitedStates/GovernmentBond", dates)
DC <- switch(frequency,
S = DiscountCurve(L6m$params, L6m$tsQuotes, yearFrac(L6m$params$tradeDate, dates)),
Q = DiscountCurve(L3m$params, L3m$tsQuotes, yearFrac(L3m$params$tradeDate, dates)),
|
