aboutsummaryrefslogtreecommitdiffstats
path: root/R/calibration.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/calibration.R')
-rw-r--r--R/calibration.R12
1 files changed, 6 insertions, 6 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 1a8242e8..bf79c8e4 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -50,12 +50,12 @@ set.singlenamesdata <- function(index, tradedate){
}
index$portfolio <- c(index$portfolio, buildSC(quote, cds.cs$cs, cds.cs$cdsdates))
}
- if(index$name == "EU9"){
- index$issuerweights <- rep(0.08, 123)
- index$issuerweights[quotes$ticker=="GDFS"] <- 0.08*2
- index$issuerweights[quotes$ticker=="GASSM"] <- 0.08*2
- }
index$issuerweights <- rep(1/length(index$portfolio), length(index$portfolio))
+ ## group common curves
+ index$issuerweights <- aggregate(index$issuerweights,
+ by = list(unlist(lapply(index$portfolio, function(x)x@issuer))),
+ sum)[,2]
+ index$portfolio <- unique(index$portfolio)
index$recov <- sapply(index$portfolio, attr, "recovery")
return( index )
}
@@ -87,7 +87,7 @@ set.tranchedata <- function(index, tradedate){
tweak <- tweakcurves(index, tradedate)
index$portfolio <- NULL
index <- c(index, tweak)
- index$defaultprob <- 1 - SPmatrix(index$portfolio, length(index$cs$dates))
+ index$defaultprob <- 1 - SPmatrix(index$portfolio, index$cs$dates)
negprob <- which(index$defaultprob<0, arr.ind=T)
if(nrow(negprob) > 0){
stop(paste(index$portfolio[[negprob[1,1]]]@issuer, "has negative probability, check single names data"))