aboutsummaryrefslogtreecommitdiffstats
path: root/R/yieldcurve.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/yieldcurve.R')
-rw-r--r--R/yieldcurve.R40
1 files changed, 6 insertions, 34 deletions
diff --git a/R/yieldcurve.R b/R/yieldcurve.R
index cf2941f9..86da47c2 100644
--- a/R/yieldcurve.R
+++ b/R/yieldcurve.R
@@ -5,7 +5,7 @@ source("db.R")
getMarkitIRData <- function(date=Sys.Date(), currency=c("USD", "EUR")) {
## returns Markit rates from serenitasdb
currency <- match.arg(currency)
- table_name <- paste(currency, "rates", sep="_")
+ table_name <- paste(currency, "OIS", "rates", sep="_")
serenitasdb <- dbConn("serenitasdb")
return( serenitasdb %>% tbl(table_name)
%>% filter(effective_date == date) %>% collect() )
@@ -22,41 +22,13 @@ nextthirdwed <- function(x) {
thirdwed(y + 30 * (y < x))
}
-buildMarkitYC <- function(MarkitData, currency=c("USD", "EUR"), futurequotes){
- currency <- match.arg(currency)
- deposits <- list()
- futures <- list()
- swaps <- list()
- if(missing(futurequotes)) {
- for(k in names(MarkitData[2:7])) {
- v <- MarkitData[[k]]
- if(is.na(v)) {
- next
- }
- deposits[[paste0("d", tolower(k))]] <- v
- }
- } else {
- for(i in seq_along(futurequotes)) {
- futures[[paste0("fut",i)]] <- futurequotes[i]
- }
- ## get last imm date
- lastimmdate <- nextthirdwed(advance(dates=tradeDate, n=21, timeUnit=2, bdc=4))
- lastfuturematurity <- advance(dates=lastimmdate, n=3, timeUnit=2, bdc=4)
- ## find out the 2 year swap rate maturity
- s2ymaturity <- advance(calendar="UnitedKingdom", dates=settleDate, 2, 3)
- if(s2ymaturity == lastfuturematurity){
- futures[["fut8"]] <- NULL
- }
- }
- for(k in names(MarkitData[8:length(MarkitData)])) {
+buildMarkitYC <- function(MarkitData, currency=c("USD", "EUR"), futurequotes) {
+ oisswaps <- list()
+ for(k in names(MarkitData[2:length(MarkitData)])) {
v <- MarkitData[[k]]
- if(is.na(v)) {
- next
- }
- swaps[[paste0("s", tolower(k))]] <- v
+ oisswaps[[paste0("ois", tolower(k))]] <- v
}
- tsQuotes <- c(deposits, futures, swaps)
- return( tsQuotes )
+ return( oisswaps )
}
exportYC <- function(tradedate=Sys.Date(), currency=c("USD", "EUR"), useFutures=FALSE) {