aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/mlpdb.R8
1 files changed, 7 insertions, 1 deletions
diff --git a/R/mlpdb.R b/R/mlpdb.R
index 08a0721d..f3ae8ee7 100644
--- a/R/mlpdb.R
+++ b/R/mlpdb.R
@@ -51,9 +51,15 @@ indexsplit <- function(indexname){
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'",
+ "and series=%s and quotedate::date='%s' and tenor = '%s'",
"and quotesource='MKIT' order by attach asc")
temp <- indexsplit(indexname)
r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date, tenor))
+ if(nrow(r)==0){
+ sqlstr <- paste("select * from tranche_quotes where index='%s'",
+ "and series=%s and quotedate::date='%s' and tenor = '%s'",
+ "order by attach asc")
+ r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date, tenor))
+ }
return( r )
}