diff options
Diffstat (limited to 'R/mlpdb.R')
| -rw-r--r-- | R/mlpdb.R | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -39,3 +39,20 @@ get.indexquotes <- function(indexname, date=Sys.Date()){ recovery_curve = arr.convert(r$recovery_curve)) return( quotes ) } + +indexsplit <- function(indexname){ + r <- regexpr("(\\D*)(\\d*)", indexname, perl=T) + cs <- attr(r, "capture.start") + cl <- attr(r, "capture.length") + index <- substr(indexname, cs[1], cs[1]+cl[1]-1) + series <- substr(indexname, cs[2], cs[2]+cl[2]-1) + 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") + temp <- indexsplit(indexname) + r <- dbGetQuery(mlpdbCon, sprintf(sqlstr, temp$index, temp$series, date)) + return( r ) +} |
