aboutsummaryrefslogtreecommitdiffstats
path: root/R/mlpdb.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/mlpdb.R')
-rw-r--r--R/mlpdb.R10
1 files changed, 5 insertions, 5 deletions
diff --git a/R/mlpdb.R b/R/mlpdb.R
index fd1f17f4..2c8eadba 100644
--- a/R/mlpdb.R
+++ b/R/mlpdb.R
@@ -13,7 +13,7 @@ load.index <- function(name, date=Sys.Date(), tenor="5yr"){
id <- nameToBasketID(name, date)
sqlstr <- "SELECT indexfactor, cumulativeloss, maturity from index_desc where basketid=%s and tenor='%s'"
r <- as.list(dbGetQuery(mlpdbCon, sprintf(sqlstr, id, tenor)))
- return(list(coupon=0.05, factor=r$indexfactor/100, maturity=r$maturity,
+ return(list(tenor=tenor, factor=r$indexfactor/100, maturity=r$maturity,
loss=r$cumulativeloss/100, recovery=0.4, name=name))
}
@@ -49,10 +49,10 @@ indexsplit <- function(indexname){
return(list(index=toupper(index), series=series))
}
-get.tranchequotes <- function(indexname, date=Sys.Date()){
- sqlstr <- paste("select * from quotes where index='%s'",
- "and series=%s and quotedate='%s' order by attach asc")
+get.tranchequotes <- function(indexname, tenor='5yr', date=Sys.Date()){
+ sqlstr <- paste("select * from tranche_quotes where index='%s'",
+ "and series=%s and quotedate='%s' and tenor = '%s' order by attach asc")
temp <- indexsplit(indexname)
- r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date))
+ r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date, tenor))
return( r )
}