diff options
| -rw-r--r-- | R/thetas-durations.R | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/R/thetas-durations.R b/R/thetas-durations.R index a1cbaa4c..90646b06 100644 --- a/R/thetas-durations.R +++ b/R/thetas-durations.R @@ -83,17 +83,19 @@ 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', 'EU')) { - recov <- if(index == 'IG' || index == 'EU') 0.4 else 0.3 - coupon <- if(index == 'IG'|| index == 'EU') 0.01 else 0.05 +for(index in c('IG', 'HY', 'EU', 'XO')) { + recov <- if(index %in% c('IG', 'EU')) 0.4 else 0.3 + coupon <- if(index %in% c('IG', '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) { + EU = c("3yr", "5yr", "7yr", "10yr"), + XO = c("3yr", "5yr", "7yr", "10yr")) + if( index %in% c('EU', 'XO') && series == 29) { next } + indexquotes <- get.indexquotes.table(index, series, tenors) if(nrow(indexquotes) == 0) { next @@ -105,7 +107,7 @@ for(index in c('IG', 'HY', 'EU')) { last_maturity <- maturities %>% slice(n()) %>% pull(maturity) durandthetas <- foreach(i = 1:nrow(indexquotes), .combine='rbind') %dopar% { tradedate <- indexquotes %>% slice(i) %>% pull(date) - exportYC(tradedate) + exportYC(tradedate, currency = if (index %in% c("IG", "HY")) "USD" else "EUR") cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), last_maturity, "Q", "FIXED", 1, 0, tradedate, IMMDate(tradedate, "prev")) quotes <- data.frame(upfront=(100-as.numeric(indexquotes[i,maturities$tenor]))/100, @@ -118,7 +120,7 @@ for(index in c('IG', 'HY', 'EU')) { ## durandthetas <- c() ## for(i in 1:nrow(indexquotes)) { ## tradedate <- indexquotes %>% slice(i) %>% pull(date) - ## exportYC(tradedate) + ## exportYC(tradedate, currency = if (index %in% c("IG", "HY")) "USD" else "EUR") ## cs <- couponSchedule(IMMDate(tradedate, noadj=TRUE), last_maturity,"Q", "FIXED", 1, ## 0, tradedate, IMMDate(tradedate, "prev")) ## quotes <- data.frame(upfront=(100-as.numeric(indexquotes[i,maturities$tenor]))/100, |
