aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/thetas-durations.R16
1 files changed, 11 insertions, 5 deletions
diff --git a/R/thetas-durations.R b/R/thetas-durations.R
index 9a7362be..a1cbaa4c 100644
--- a/R/thetas-durations.R
+++ b/R/thetas-durations.R
@@ -1,4 +1,3 @@
-library(ggplot2)
library(lubridate)
library(doParallel)
library(dplyr)
@@ -84,11 +83,17 @@ sqlstr.duration <- paste("UPDATE index_quotes set duration=$1 where date=$2 and
sqlstr.theta <- paste("UPDATE index_quotes set theta=$1 where date=$2 and index=$3",
"and series=$4 and tenor=$5")
-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(index in c('IG', 'HY', 'EU')) {
+ recov <- if(index == 'IG' || index == 'EU') 0.4 else 0.3
+ coupon <- if(index == 'IG'|| index == 'EU') 0.01 else 0.05
for(series in 18:29) {
+ tenors <- switch(index,
+ IG = c("3yr", "5yr", "7yr", "10yr"),
+ HY = c("3yr", "5yr", "7yr"),
+ EU = if (series < 22) c("5yr", "7yr", "10yr") else c("3yr", "5yr", "7yr", "10yr"))
+ if( index == 'EU' && series == 29) {
+ next
+ }
indexquotes <- get.indexquotes.table(index, series, tenors)
if(nrow(indexquotes) == 0) {
next
@@ -155,6 +160,7 @@ for(index in c('IG', 'HY')) {
}
}
## ## nice plot, now I'm just showing off
+## library(ggplot2)
## ggplot(df.durations, aes(x=date))+geom_line(aes(y=`3yr`, colour="3yr"))+
## geom_line(aes(y=`5yr`, colour="5yr"))+
## geom_line(aes(y=`7yr`, colour="7yr"))+ylab("duration")+labs(colour="tenor")