diff options
Diffstat (limited to 'R/cds_functions_generic.R')
| -rw-r--r-- | R/cds_functions_generic.R | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index 3dea5d17..19d27b19 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -472,6 +472,12 @@ bondhazardrate.shaped <- function(collateral, shape, R=0.4, alpha=0.25, beta=15) sc <- new("shapedcurve", h=0.05, shape=shape, alpha=alpha, beta=beta)
eps <- 1e-8
counter <- 0
+ if(collateral$price<1){
+ cat("price is too low\n")
+ h <- 1e6
+ return( shapedtodpc(cs, sc) )
+ }
+
while(abs(bondpv(cs, sc, R) - collateral$price/100) > eps){
dh <- (collateral$price/100 - bondpv(cs, sc, R))/dbondpv(cs, sc, R)
while(sc@h+dh<0){
|
