diff options
Diffstat (limited to 'R/thetas-durations.R')
| -rw-r--r-- | R/thetas-durations.R | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/R/thetas-durations.R b/R/thetas-durations.R index 02001187..98ddd822 100644 --- a/R/thetas-durations.R +++ b/R/thetas-durations.R @@ -20,7 +20,7 @@ source(file.path(root.dir, "code", "R", "cds_functions_generic.R")) source(file.path(root.dir, "code", "R", "yieldcurve.R")) get.indexquotes <- function(index, series, tenors=c("3yr", "5yr", "7yr"), onlymissing=TRUE){ - arraystring1 <- paste0("Array[''", paste(tenors, collapse = "'', ''"), "'']::tenor[]") + arraystring1 <- paste0(sqlArray(sqlQuote(sqlQuote(tenors))), "::tenor[]") arraystring2 <- paste0('"', paste(tenors, collapse='" float, "'), '" float') sqlstr <- paste("select * from crosstab('select date, tenor, closeprice from index_quotes", "where index=''%s''and series=%s") @@ -36,10 +36,9 @@ get.indexquotes <- function(index, series, tenors=c("3yr", "5yr", "7yr"), onlymi get.indexmaturity <- function(index, series){ sqlstr <- paste("select maturity, coupon/cast(10000 as float)as running, tenor", - "from index_maturity where index='%s'", - "and series=%s order by maturity") - stmt <- sprintf(sqlstr, index, series) - df <- dbGetQuery(serenitasdb, stmt) + "from index_maturity where index=$1", + "and series=$2 order by maturity") + df <- dbGetQuery(serenitasdb, sqlstr, params=list(index, series)) return( df ) } |
