diff options
Diffstat (limited to 'R/thetas-durations.R')
| -rw-r--r-- | R/thetas-durations.R | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/R/thetas-durations.R b/R/thetas-durations.R index ad4ee63c..068ad6db 100644 --- a/R/thetas-durations.R +++ b/R/thetas-durations.R @@ -82,7 +82,6 @@ fasttheta <- function(sc, cs, recov, tradedate, maturities, quotes, fixedrate=0. return( r ) } -tenors <- c("3yr", "5yr", "7yr", "10yr") sqlstr.duration <- paste("UPDATE index_quotes set duration=$1 where date=$2 and index=$3", "and series=$4 and tenor=$5") sqlstr.theta <- paste("UPDATE index_quotes set theta=$1 where date=$2 and index=$3", @@ -90,6 +89,7 @@ sqlstr.theta <- paste("UPDATE index_quotes set theta=$1 where date=$2 and index= for(index in c('IG', 'HY')){ recov <- if(index=='IG') 0.4 else 0.3 coupon <- if(index=='IG') 0.01 else 0.05 + tenors <- if(index=='IG') c("3yr", "5yr", "7yr", "10yr") else c("3yr", "5yr", "7yr") for(series in c(18, 19, 20, 21, 22, 23, 24, 25)){ indexquotes <- get.indexquotes.table(index, series, tenors) if(nrow(indexquotes)==0){ @@ -110,6 +110,9 @@ for(index in c('IG', 'HY')){ c(fastduration(sc, cs, tradedate, maturities$maturity), fasttheta(sc, cs, recov, tradedate, maturities$maturity, quotes$upfront, coupon)) } + if(is.null(dim(durandthetas))){ + dim(durandthetas) <- c(1, length(durandthetas)) + } ## non parallel version for easier debugging ## durandthetas <- c() ## for(i in 1:nrow(indexquotes)){ |
