aboutsummaryrefslogtreecommitdiffstats
path: root/R/calibration.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/calibration.R')
-rw-r--r--R/calibration.R10
1 files changed, 6 insertions, 4 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 9a298f6d..040c8b8f 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -55,15 +55,17 @@ set.tranchedata <- function(index, tradedate){
if(index$name=="ig19" || index$name=="ig21"){
index$quotes$spread <- 0.01
}
- index$cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), index$maturity,"Q", "FIXED",
- index$quotes$spread[1],
+ index$cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), index$maturity,"Q", "FIXED", 1,
0, tradedate, IMMDate(tradedate, "prev"))
if(!is.na(temp$indexrefprice[1])&&temp$indexrefprice[1]!=0){
index$quotes$price <- temp$indexrefprice[1]/100
}else{
+ ##rewrite as a snac function
sc <- new("flatcurve", h=temp$indexrefspread[1]*1e-4/(1-index$recovery))
- index$quotes$price <- 1 + cdspv(index$cs, sc, index$recovery, tradedate)-
- cdsAccrued(tradedate, index$quotes$spread[1])
+ startdate <- tradedate + 1
+ cds.pv <- couponleg(index$cs, sc, startdate)*index$quotes$spread -
+ defaultleg(index$cs, sc, index$recovery, startdate)
+ index$quotes$price <- 1 + cds.pv - cdsAccrued(tradedate, index$quotes$spread[1])
}
index$portfolio <- tweakcurves(index, tradedate)$portfolio
index$defaultprob <- 1 - SPmatrix(index$portfolio, length(index$cs$dates))