diff options
| -rw-r--r-- | R/build_portfolios.R | 2 | ||||
| -rw-r--r-- | R/build_scenarios.R | 4 | ||||
| -rw-r--r-- | R/cds_functions_generic.R | 4 |
3 files changed, 6 insertions, 4 deletions
diff --git a/R/build_portfolios.R b/R/build_portfolios.R index 86d943ac..d5ffda3d 100644 --- a/R/build_portfolios.R +++ b/R/build_portfolios.R @@ -64,7 +64,7 @@ for(i in seq_along(dealnames)){ nullcurves <- unlist(lapply(deal.portfolio$SC, is.null))
deal.portfolio$SC <- deal.portfolio$SC[!nullcurves]
deal.portfolio$notional <- deal.portfolio$notional[!nullcurves]
- A <- SPmatrix2(deal.portfolio$SC, deal.data, freq="3 months", workdate)
+ A <- SPmatrix2(deal.portfolio$SC, deal.data, freq="Quarterly", workdate)
S <- 1 - sapply(deal.portfolio$SC, attr, "recov")
deal.weights <- deal.portfolio$notional/sum(deal.portfolio$notional)
deal.spread5y <- portfoliospread(deal.portfolio, index$maturity, workdate)
diff --git a/R/build_scenarios.R b/R/build_scenarios.R index b5d485aa..a2c0c190 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -109,12 +109,12 @@ for(j in seq_along(dealnames)){ intexrecov[,i] <- recov.adj * (scenariosr[,i]-scenariosr[,i-1])/(scenariosd[,i]-scenariosd[,i-1])
}
}
- deal.dates <- getdealschedule(deal.data, "3 months")
+ deal.dates <- getdealschedule(deal.data, "Quarterly")
deal.dates <- deal.dates[deal.dates>=settledate]
cdr <- cdrfromscenarios(scenariosd, deal.dates, tradedate)
## linear approximation for monthly scenarios
deal.data <- getdealdata(dealnames[j], tradedate)
- deal.datesmonthly <- getdealschedule(deal.data, "1 month")
+ deal.datesmonthly <- getdealschedule(deal.data, "Monthly")
deal.datesmonthly <- deal.datesmonthly[deal.datesmonthly>=settledate]
cdrmonthly <- matrix(0, n.scenarios, length(deal.datesmonthly))
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R index 1076ce7e..bf43bcd0 100644 --- a/R/cds_functions_generic.R +++ b/R/cds_functions_generic.R @@ -811,9 +811,11 @@ DP2 <- function(sc, dates, startdate=Sys.Date()){ prepayprob = cumsum(pfun(x2T) * Qmid * dT)))
}
-SPmatrix2 <- function(portfolio, dealdata, freq="3 months", startdate=Sys.Date()){
+SPmatrix2 <- function(portfolio, dealdata, freq=c("Quarterly", "Monthly"),
+ startdate=Sys.Date()){
## computes the default and prepay probability matrix of a portfolio
## at the dates specified from dealdata
+ freq <- match.arg(freq)
dates <- getdealschedule(dealdata, freq)
dates <- dates[dates>=addBusDay(startdate, 3)]
DP <- matrix(0, length(portfolio), length(dates))
|
