aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/yieldcurve.R28
1 files changed, 13 insertions, 15 deletions
diff --git a/R/yieldcurve.R b/R/yieldcurve.R
index 033e6d57..f5adc987 100644
--- a/R/yieldcurve.R
+++ b/R/yieldcurve.R
@@ -56,12 +56,8 @@ buildMarkitYC <- function(MarkitData, currency="USD", futurequotes){
futures <- list()
swaps <- list()
if(missing(futurequotes)){
- keys <- c("d1m", "d2m", "d3m", "d6m")
- if(currency=="EUR"){
- keys <- c(keys, "d9m", "d1y")
- }else{
- keys <- c(keys, "d1y")
- }
+ keys <- unlist(lapply(MarkitData$deposits[5:length(MarkitData$deposits)],
+ function(x)paste0("d",tolower(x$tenor))), use.names=FALSE)
for(i in seq_along(keys)){
deposits[[keys[i]]] <- as.numeric(MarkitData$deposits[i+4]$curvepoint$parrate)
}
@@ -78,21 +74,23 @@ buildMarkitYC <- function(MarkitData, currency="USD", futurequotes){
futures[["fut8"]] <- NULL
}
}
- keys <- unlist(lapply(MarkitData$swaps[8:length(MarkitData$swaps)],
- function(x) paste0("s", tolower(x$tenor))),use.names=FALSE)
- for(i in seq_along(keys)){
- swaps[[keys[i]]] <- as.numeric(MarkitData$swaps[i+7]$curvepoint$parrate)
- }
- if(.Platform$OS.type != "unix"){
- for(missingtenor in c("s4y", "s6y", "s7y", "s8y", "s9y", "s12y", "s25y")){
- swaps[[missingtenor]] <- NULL
+ if(length(MarkitData$swaps)>8){## swaps quotes probably missing
+ keys <- unlist(lapply(MarkitData$swaps[8:length(MarkitData$swaps)],
+ function(x) paste0("s", tolower(x$tenor))),use.names=FALSE)
+ for(i in seq_along(keys)){
+ swaps[[keys[i]]] <- as.numeric(MarkitData$swaps[i+7]$curvepoint$parrate)
+ }
+ if(.Platform$OS.type != "unix"){
+ for(missingtenor in c("s4y", "s6y", "s7y", "s8y", "s9y", "s12y", "s25y")){
+ swaps[[missingtenor]] <- NULL
+ }
}
}
tsQuotes <- c(deposits, futures, swaps)
return( tsQuotes )
}
-exportYC <- function(tradedate=Sys.Date(), currency="USD", curveType, useFutures=FALSE){
+exportYC <- function(tradedate=Sys.Date(), currency="USD", useFutures=FALSE){
## export the Yield Curve into the environment
require(RQuantLib)
if(useFutures){