aboutsummaryrefslogtreecommitdiffstats
path: root/R/calibrate_tranches.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/calibrate_tranches.R')
-rw-r--r--R/calibrate_tranches.R22
1 files changed, 11 insertions, 11 deletions
diff --git a/R/calibrate_tranches.R b/R/calibrate_tranches.R
index 3e2599fc..178f23ae 100644
--- a/R/calibrate_tranches.R
+++ b/R/calibrate_tranches.R
@@ -1,11 +1,11 @@
library("parallel")
-setwd("//WDSENTINEL/share/CorpCDOs/R")
-source("cds_utils.R")
-source("cds_functions_generic.R")
-source("index_definitions.R")
-source("tranche_functions.R")
-source("yieldcurve.R")
-source("optimization.R")
+root.dir <- "//WDSENTINEL/share/CorpCDOs/"
+source(file.path(root.dir, "code", "R", "cds_utils.R"))
+source(file.path(root.dir, "code", "R", "cds_functions_generic.R"))
+source(file.path(root.dir, "code", "R", "index_definitions.R"))
+source(file.path(root.dir, "code", "R", "tranche_functions.R"))
+source(file.path(root.dir, "code", "R", "yieldcurve.R"))
+source(file.path(root.dir, "code", "R", "optimization.R"))
cl <- makeCluster(6)
@@ -19,7 +19,7 @@ setEvaluationDate(as.Date(MarkitData$effectiveasof))
## calibrate HY19
## calibrate the single names curves
singlenames.data <- read.table(file="clipboard", sep="\t", header=T)
-nondefaulted <- singlenames.data[!singlenames.data$ticker %in% hy17$defaulted,]
+nondefaulted <- singlenames.data[!singlenames.data$ticker %in% hy19$defaulted,]
bps <- 1e-4
cdsdates <- as.Date(character(0))
@@ -66,7 +66,7 @@ SurvProb <- SPmatrix(hy19portfolio.tweaked, hy19)
## load common parameters
K <- c(0, 0.15, 0.25, 0.35, 1)
Kmodified <- adjust.attachments(K, hy19$loss, hy19$factor)
-tranche.upf <- c(37.5625, 87.25, 101.8125, 115.0625)
+tranche.upf <- c(37.8125, 87.375, 102.125, 114.96875)
tranche.running <- c(0.05, 0.05, 0.05, 0.05)
Ngrid <- 2*nrow(nondefaulted)+1
@@ -118,7 +118,7 @@ clusterExport(cl, list("shockprob", "issuerweights", "rho", "Z", "lossrecovdist.
parf <- function(i){
pshocked <- apply(p, 2, shockprob, rho=rho, Z=Z[i])
S <- 1 - Rstoch[i,,]
- dist <- lossrecovdist.term(pshocked,, issuerweights, S, Ngrid)
+ dist <- lossrecovdist.term(pshocked, , issuerweights, S, Ngrid)
return( tranche.pvvec(Kmodified, dist$L, dist$R, cs))
}
@@ -152,7 +152,7 @@ for(l in 1:100){
cat(err,"\n")
}
-write.table(data.frame(Z=Z, w=w.mod), file=paste0("calibration-", Sys.Date(), ".csv"), col.names=T, row.names=F, sep=",")
+write.table(data.frame(Z=Z, w=w.mod), file=file.path(root.dir, "Scenarios", paste0("calibration-", Sys.Date(), ".csv")), col.names=T, row.names=F, sep=",")
## computes MFdeltas
newportf <- hy19portfolio.tweaked