diff options
| -rw-r--r-- | R/mlpdb.R | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -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 ) } |
