aboutsummaryrefslogtreecommitdiffstats
path: root/R
diff options
context:
space:
mode:
Diffstat (limited to 'R')
-rw-r--r--R/calibration.R6
-rw-r--r--R/serenitasdb.R8
2 files changed, 9 insertions, 5 deletions
diff --git a/R/calibration.R b/R/calibration.R
index 4e8cac31..23441583 100644
--- a/R/calibration.R
+++ b/R/calibration.R
@@ -66,11 +66,7 @@ set.tranchedata <- function(index, tradedate){
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$quotes$spread <- couponfromindex(index, 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){
diff --git a/R/serenitasdb.R b/R/serenitasdb.R
index 86299d41..6e6d5344 100644
--- a/R/serenitasdb.R
+++ b/R/serenitasdb.R
@@ -106,3 +106,11 @@ get.tranchequotes <- function(indexname, tenor='5yr', date=Sys.Date()){
}
return( r )
}
+
+couponfromindex <- function(indexname, tenor){
+ temp <- indexsplit(indexname)
+ sqlstr <- sprintf("select coupon from index_maturity where index='%s' and series=%s and tenor='%s'",
+ temp$index, temp$series, tenor)
+ r <- dbGetQuery(serenitasdb, sqlstr)
+ r$coupon
+}