aboutsummaryrefslogtreecommitdiffstats
path: root/R/mlpdb.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/mlpdb.R')
-rw-r--r--R/mlpdb.R17
1 files changed, 17 insertions, 0 deletions
diff --git a/R/mlpdb.R b/R/mlpdb.R
index 70190d4b..fd1f17f4 100644
--- a/R/mlpdb.R
+++ b/R/mlpdb.R
@@ -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 )
+}