diff options
| -rw-r--r-- | R/mlpdb.R | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -62,7 +62,13 @@ get.tranchequotes <- function(indexname, tenor='5yr', date=Sys.Date()){ "and tenor = '%s' order by attach asc") r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date, tenor)) ## check if set is unique and complete - if(length(unique(r$attach))==length(r$attach) && all(c(r$attach, 100)==c(0, r$detach))){ + ## hy9 and hy10 tranche is gone + if(tolower(indexname) %in% c("hy9", "hy10")){ + lower.attach <- 10 + }else{ + lower.attach <- 0 + } + if(length(unique(r$attach))==length(r$attach) && all(c(r$attach, 100)==c(lower.attach, r$detach))){ return(r) } @@ -77,11 +83,11 @@ get.tranchequotes <- function(indexname, tenor='5yr', date=Sys.Date()){ for(i in 1:nrow(distinct.quotes)){ sqlstr <- paste("select * from tranche_quotes where index='%s'", "and series=%s and tenor = '%s' and quotedate='%s'", - "and detach-attach!=5 and quotesource='%s' order by attach asc") + "and detach not in(5,10) and quotesource='%s' order by attach asc") r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, tenor, distinct.quotes$quotedate[i], distinct.quotes$quotesource[i])) - if(all(c(r$attach, 100)==c(0, r$detach))){#set is complete + if(all(c(r$attach, 100)==c(lower.attach, r$detach))){#set is complete flag <- TRUE break } |
