aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/build_scenarios.R27
1 files changed, 13 insertions, 14 deletions
diff --git a/R/build_scenarios.R b/R/build_scenarios.R
index b49f99e7..80a37c19 100644
--- a/R/build_scenarios.R
+++ b/R/build_scenarios.R
@@ -116,7 +116,7 @@ reinvfixed <- 0.07
basecase.rollingmaturity <- 84 ##months
reinvlag <- 3 ##months
n.scenarios <- 100
-recov.adj <- 0.925
+recov.adj <- 1
for(j in seq_along(dealnames)){
@@ -211,21 +211,19 @@ for(j in seq_along(dealnames)){
reinvassets <- get.reinvassets(dealnames[j], workdate)
reinvprices <- list()
- for(n.asset in seq_along(reinvassets)){
- asset <- reinvassets[[n.asset]]
- reinvprices[[names(reinvassets)[n.asset]]] <- numeric(length(deal.datesmonthly))
+ for(assetname in names(reinvassets)){
+ asset <- reinvassets[[assetname]]
+ reinvprices[[assetname]] <- numeric(length(deal.datesmonthly))
if(asset$coupontype=="FLOAT") {
coupon <- reinvspread
- R <- 0.7
}else{
coupon <- reinvfixed
- R <- 0.3
}
for(i in seq_along(deal.datesmonthly)){
- reinvprices[[names(reinvassets)[n.asset]]][i] <-
+ reinvprices[[assetname]][i] <-
100 * forwardportfolioprice(deal.portfolio, deal.datesmonthly[i],
min(deal.datesmonthly[i]+rollingmaturity*30, deal.data$maturity),
- asset$coupontype, coupon, R, asset$liborfloor/100)
+ asset$coupontype, coupon, asset$liborfloor/100)
}
}
## reinvprices <- compute.reinvprices(df, forwards, cdrmonthly, recoverymonthly, reinvspread,
@@ -290,14 +288,15 @@ for(j in seq_along(dealnames)){
cat("[config]\n", file = configfile)
cat(paste("rollingmat", as.integer(rollingmaturity), sep="="), "\n",
append=TRUE, file = configfile)
- if(reinvflags[j]){
- cat(paste("reinvflag", "True", sep="="), "\n", append= TRUE,
- file = configfile)
- }else{
- cat(paste("reinvflag", "False", sep="="), "\n", append= TRUE,
- file = configfile)
+
+ topythonbool <- function(x){
+ stopifnot(is.logical(x))
+ return(if(x) "True" else "False")
}
+ cat(paste("reinvflag", topythonbool(reinvflags[j]), sep="="), "\n",
+ append = TRUE, file=configfile)
+
save(scenariosd, scenariosr, dist.joint, file=file.path(save.dir, paste0(dealnames[j], ".RData")),
compress="xz")