diff options
| -rw-r--r-- | R/build_scenarios.R | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/R/build_scenarios.R b/R/build_scenarios.R index 9225d094..6df618f6 100644 --- a/R/build_scenarios.R +++ b/R/build_scenarios.R @@ -1,3 +1,11 @@ +library(doParallel)
+hostname <- system("hostname", intern=TRUE)
+if(hostname=="debian"){
+ registerDoParallel(8)
+}else{
+ registerDoParallel(4)
+}
+
args <- commandArgs(trailingOnly=TRUE)
if(.Platform$OS.type == "unix"){
@@ -222,11 +230,11 @@ for(j in seq_along(dealnames)){ }
#reinvest tweak
coupon <- coupon-0.0075
- for(i in seq_along(deal.datesmonthly)){
- reinvprices[[assetname]][i] <-
- 100 * forwardportfolioprice(deal.portfolio, deal.datesmonthly[i],
- min(deal.datesmonthly[i]+rollingmaturity*30, deal.data$maturity),
- asset$coupontype, coupon, asset$liborfloor/100)
+
+ reinvprices[[assetname]] <- foreach(i = icount(length(deal.datesmonthly))) %dopar% {
+ 100 * forwardportfolioprice(deal.portfolio, deal.datesmonthly[i],
+ min(deal.datesmonthly[i]+rollingmaturity*30, deal.data$maturity),
+ asset$coupontype, coupon, asset$liborfloor/100)
}
}
## reinvprices <- compute.reinvprices(df, forwards, cdrmonthly, recoverymonthly, reinvspread,
|
