aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/thetas-durations.R10
1 files changed, 8 insertions, 2 deletions
diff --git a/R/thetas-durations.R b/R/thetas-durations.R
index c441140d..ccd0f4a4 100644
--- a/R/thetas-durations.R
+++ b/R/thetas-durations.R
@@ -104,6 +104,11 @@ sqlstr.theta <- paste("UPDATE index_quotes set theta=$1 where date=$2 and index=
for(series in c(16, 17, 18, 19, 20, 21, 22, 23)){
indexquotes <- get.indexquotes(index, series)
+ indexquotes <- indexquotes[!(is.na(indexquotes[,"3yr"]) & is.na(indexquotes[,"5yr"])
+ & is.na(indexquotes[,"7yr"])),]
+ if(nrow(indexquotes)==0){
+ next
+ }
maturities <- get.indexmaturity(index, series)
maturities <- maturities[maturities$tenor %in% tenors,]
indexquotes <- indexquotes[indexquotes$date<=maturities$maturity[3],]
@@ -131,8 +136,9 @@ for(series in c(16, 17, 18, 19, 20, 21, 22, 23)){
r <- rbind(r, c(fastduration(sc, cs, tradedate, maturities$maturity),
fasttheta(sc, cs, recov, tradedate, maturities$maturity, quotes$upfront)))
}
- df.durations <- data.frame(date=indexquotes$date, r[,1:3])
- df.thetas <- data.frame(date=indexquotes$date, r[,4:6])
+
+ df.durations <- data.frame(date=indexquotes$date, r[,1:3, drop=F])
+ df.thetas <- data.frame(date=indexquotes$date, r[,4:6, drop=F])
colnames(df.durations) <- c("date", tenors)
colnames(df.thetas) <- c("date", tenors)
for(i in 1:nrow(df.durations)){