aboutsummaryrefslogtreecommitdiffstats
path: root/R/intex_deal_functions.R
diff options
context:
space:
mode:
Diffstat (limited to 'R/intex_deal_functions.R')
-rw-r--r--R/intex_deal_functions.R14
1 files changed, 8 insertions, 6 deletions
diff --git a/R/intex_deal_functions.R b/R/intex_deal_functions.R
index 6020f5e7..38637dc5 100644
--- a/R/intex_deal_functions.R
+++ b/R/intex_deal_functions.R
@@ -365,13 +365,14 @@ getpayday <- function(dealdata, tradedate){
m <- m %%3+9
y <- as.numeric(format(tradedate, "%Y"))
y <- y - 1
- payday <- as.Date(sprintf("%s-%s-%s",y, m, dealdata$pay_day))
+ payday <- as.Date(sprintf("%s-%s-%s", y, m, dealdata$pay_day))
i <- 1
- nextdate <- advance(calendar = "UnitedStates", dates=payday, 3*i, 2, bdc=4)
+ cal <- Calendar$new("UnitedStates")
+ nextdate <- cal$advance(dates=payday, period = "3m", bdc = "Unadjusted")
while(nextdate < tradedate){
payday <- nextdate
i <- i+1
- nextdate <- advance(calendar = "UnitedStates", dates=payday, 3*i, 2, bdc=4)
+ nextdate <- cal$advance(payday, 3*i, 2, bdc = "Unadjusted")
}
return(payday)
}
@@ -381,12 +382,13 @@ getdealschedule <- function(dealdata, freq="1 month", tradedate=Sys.Date(), lag=
n <- if(freq == "1 month") 1 else 3
sched <- payday
i <- 1
- bdc <- if(adjust) 0 else 4
- nextdate <- advance(calendar = "UnitedStates", dates=payday, n*i, 2, bdc=bdc)
+ bdc <- if(adjust) "Following" else "Unadjusted"
+ cal <- Calendar$new("UnitedStates")
+ nextdate <- cal$advance(payday, n*i, 2, bdc = bdc)
while(nextdate<= dealdata$"maturity" + lag){
sched <- c(sched, nextdate)
i <- i+1
- nextdate <- advance(calendar = "UnitedStates", dates=payday, n*i, 2, bdc=bdc)
+ nextdate <- cal$advance(payday, n*i, 2, bdc = bdc)
}
##always add the maturity
if(sched[length(sched)] < dealdata$maturity){