diff options
Diffstat (limited to 'cds_functions_generic.R')
| -rw-r--r-- | cds_functions_generic.R | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/cds_functions_generic.R b/cds_functions_generic.R index edffe25c..e6e5a654 100644 --- a/cds_functions_generic.R +++ b/cds_functions_generic.R @@ -49,7 +49,7 @@ setMethod("couponleg", signature("data.frame", "defaultcurve"), ## and a survival curve. Also called premium leg or fixed leg.
function(cs, sc, accruedondefault=TRUE){
x1T <- yearFrac(today(), sc@dates)
- x2T <- yearFrac(today(), cs@dates)
+ x2T <- yearFrac(today(), cs$dates)
dT <- diff(c(0, x2T))
hfun <- approxfun(x1T, sc@hazardrates, method="constant", rule=2)
PD <- cumprod(exp(- hfun(x2T) * dT))
@@ -462,7 +462,6 @@ cdshazardrate <- function(quotes, R=0.4){ hvec <- c(previous.hvec, rep(new.h, flength))
sc <- new("defaultcurve", dates=cs$dates, hazardrates=hvec)
index <- c(rep(0, length(previous.hvec)), rep(1, flength))
-
while(abs(cdspv(cs, sc, R) + quotes$upfront[i]) > eps){
new.h <- new.h - (quotes$upfront[i] + cdspv(cs, sc, R))/dcdspv(cs, sc, R, index)
hvec <- c(previous.hvec, rep(new.h, flength))
|
