aboutsummaryrefslogtreecommitdiffstats
path: root/R/cds_functions_generic.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/cds_functions_generic.R')
-rw-r--r--R/cds_functions_generic.R6
1 files changed, 3 insertions, 3 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R
index e8fd569d..2cb53efc 100644
--- a/R/cds_functions_generic.R
+++ b/R/cds_functions_generic.R
@@ -545,14 +545,14 @@ cdshazardrate <- function(quotes, R=0.4, tradedate=Sys.Date(), cs.all){
while(abs(cdspv(cs, sc, R, tradedate) + quotes$upfront[i] - acc) > eps && count < 500) {
dh <- - (quotes$upfront[i] + cdspv(cs, sc, R, tradedate) - acc)/
dcdspv(cs, sc, R, tradedate, index)
- while( (new.h + dh) < 0 ) {
- dh <- dh * 0.8
- }
new.h <- new.h + dh
hvec <- c(previous.hvec, rep(new.h, flength))
sc@hazardrates <- hvec
count <- count + 1
}
+ if (count == 500) {
+ cat(sprintf("could not compute hazard rate for %s\n", quotes$maturity[i]))
+ }
previous.hvec <- hvec
previous.maturity <- maturity
previous.cs <- cs