diff options
Diffstat (limited to 'cds_functions_generic.R')
| -rw-r--r-- | cds_functions_generic.R | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/cds_functions_generic.R b/cds_functions_generic.R index a17c2a1f..edffe25c 100644 --- a/cds_functions_generic.R +++ b/cds_functions_generic.R @@ -627,8 +627,7 @@ DP2 <- function(sc, dates){ x1T <- yearFrac(today(), sc@dates)
hfun <- approxfun(x1T, sc@hazardrates, method="constant", rule=2)
pfun <- approxfun(x1T, sc@prepayrates, method="constant", rule=2)
- Q <- cumprod(exp(-(hfun(x2T)+pfun(x2T)) * dT))
- Qmid <- 1/2 * (c(1, Q[-length(Q)]) + Q)
+ Qmid <- exp(-cumsum((hfun(x2T)+pfun(x2T)) * dT))
list(defaultprob = cumsum(hfun(x2T) * Qmid * dT),
prepayprob = cumsum(pfun(x2T) * Qmid * dT))
}
@@ -653,7 +652,7 @@ SPmatrix2 <- function(portfolio, dealdata, freq="3 months"){ return(list(DP=DP, PP=PP))
}
-forwardportfolioprice <- function(portfolio, startdate, rollingmaturity, coupontype, margin){
+forwardportfolioprice <- function(portfolio, startdate, rollingmaturity, coupontype, margin, recovery){
forwardcs <- couponSchedule(nextpaydate=startdate+45, maturity=startdate+rollingmaturity,
frequency="Q", "FLOAT", margin, margin, startdate=startdate)
r <- rep(0, length(portfolio$SC))
|
