diff options
Diffstat (limited to 'R/cds_functions_generic.R')
| -rw-r--r-- | R/cds_functions_generic.R | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index d4c6e916..0c8415e2 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -459,10 +459,10 @@ cdshazardrate.shaped <- function(upfront, running, maturity, shape, R=0.4) { return(sc)
}
-cdshazardrate <- function(quotes, R=0.4){
+cdshazardrate <- function(quotes, R=0.4, workdate=Sys.Date()){
## bootstrap the implied hazard rate curve of the cds based on the upfront
## and running quotes, as well as maturity and recovery
- previous.maturity <- Sys.Date()
+ previous.maturity <- workdate
hvec <- c()
previous.hvec <- c()
eps <- 1e-8
@@ -472,7 +472,7 @@ cdshazardrate <- function(quotes, R=0.4){ next
}
maturity <- quotes$maturity[i]
- cs <- couponSchedule(nextIMMDate(Sys.Date()), maturity, "Q", "FIXED", quotes$running[i])
+ cs <- couponSchedule(nextIMMDate(workdate), maturity, "Q", "FIXED", quotes$running[i])
new.h <- 0.05
flength <- nrow(cs) - nrow(previous.cs)
hvec <- c(previous.hvec, rep(new.h, flength))
@@ -769,4 +769,3 @@ creditcurve.maturity <- function(creditcurve){ stop("not of class creditcurve")
}
}
-
|
