diff options
Diffstat (limited to 'R/calibration.R')
| -rw-r--r-- | R/calibration.R | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/R/calibration.R b/R/calibration.R index 936e2a2c..11f98c24 100644 --- a/R/calibration.R +++ b/R/calibration.R @@ -79,12 +79,12 @@ set.tranchedata <- function(index, tradedate){ index$quotes <- data.frame(maturity=index$maturity, refspread=temp$indexrefspread[1], refprice=temp$indexrefprice[1]) - index$quotes$spread <- couponfromindex(index$name, index$tenor)*1e-4 + index$quotes$spread <- couponfromindex(index$name, index$tenor) * 1e-4 index$cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), index$maturity, "Q", "FIXED", 1, 0, tradedate, IMMDate(tradedate, "prev")) - if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0){ + if(!is.na(index$quotes$refprice) && index$quotes$refprice != 0) { index$quotes$price <- index$quotes$refprice/100 - }else{ + } else { index$quotes$price <- snacpv(index$cs, index$quotes$refspread[1]*1e-4, index$quotes$spread, if (index$type %in% c("IG", "EU")) 0.4 else 0.3, tradedate) @@ -97,7 +97,7 @@ set.tranchedata <- function(index, tradedate){ index <- c(index, tweak) index$defaultprob <- 1 - SPmatrix(index$portfolio, index$cs$dates) negprob <- which(index$defaultprob < 0, arr.ind=T) - if(nrow(negprob) > 0){ + if(nrow(negprob) > 0) { stop(paste(index$portfolio[[negprob[1,1]]]@issuer, "has negative probability, check single names data")) } K <- c(0, temp$detach/100) @@ -105,13 +105,13 @@ set.tranchedata <- function(index, tradedate){ index$K <- adjust.attachments(K, index$loss, index$factor) ## convert snac prices to proper upfront - if(index$type == "XO"){ + if(index$type == "XO") { coupon <- 500 temp$trancheupfrontmid[4] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[4]*1e-4, coupon*1e-4, 0.4, tradedate)) temp$trancherunningmid[4] <- coupon } - if(index$type =="EU"){ + if(index$type =="EU") { if(index$series>=21){ coupon <- 100 temp$trancheupfrontmid[3] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[3]*1e-4, @@ -119,7 +119,7 @@ set.tranchedata <- function(index, tradedate){ temp$trancheupfrontmid[4] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[4]*1e-4, coupon*1e-4, 0.4, tradedate)) temp$trancherunningmid[3:4] <- coupon - }else if(index$series == 9){ + }else if(index$series == 9) { for(i in 4:5){ coupon <- 100 temp$trancheupfrontmid[i] <- 100 * ( 1 - snacpv(index$cs, temp$trancherunningmid[i]*1e-4, |
