aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/calibration.R14
1 files changed, 8 insertions, 6 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 4d77ec65..c16cdaca 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -51,19 +51,21 @@ set.singlenamesdata <- function(index, tradedate){
set.tranchedata <- function(index, tradedate){
temp <- get.tranchequotes(index$name, index$tenor, tradedate)
- index$quotes <- data.frame(spread=temp$indexrefspread[1]*1e-4,
- maturity=index$maturity,
- ref=temp$indexrefprice[1])
+ index$quotes <- data.frame(maturity=index$maturity,
+ refspread=temp$indexrefspread[1],
+ refprice=temp$indexrefprice[1])
if(index$name=="ig19" || index$name=="ig21"){
index$quotes$spread <- 0.01
+ }else{
+ index$quotes$spread <- index$quotes$refspread*1e-4
}
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
+ if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0){
+ index$quotes$price <- index$quotes$refprice/100
}else{
##rewrite as a snac function
- sc <- new("flatcurve", h=temp$indexrefspread[1]*1e-4/(1-index$recovery))
+ sc <- new("flatcurve", h=index$quotes$refspread[1]*1e-4/(1-index$recovery))
startdate <- tradedate + 1
cds.pv <- couponleg(index$cs, sc, startdate)*index$quotes$spread -
defaultleg(index$cs, sc, index$recovery, startdate)