aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--R/cds_functions_generic.R24
1 files changed, 20 insertions, 4 deletions
diff --git a/R/cds_functions_generic.R b/R/cds_functions_generic.R
index f9a88207..0596e247 100644
--- a/R/cds_functions_generic.R
+++ b/R/cds_functions_generic.R
@@ -680,11 +680,27 @@ DP2 <- function(sc, dates, startdate=Sys.Date()){
}
getdealschedule <- function(dealdata, freq="3 months", startdate = Sys.Date(), lag = 0){
- ## necessary if we want monthly schedule with quaterly pay dates
- prevpaydate <- seq(dealdata$"Deal Next Pay Date",
- dealdata$"Deal Next Pay Date"-92, by="-3 months")[2]
+ calstring <- "UnitedStates/GovernmentBond"
+ settledate <- advance(calendar = calstring,
+ dates = startdate,
+ n = 3,
+ timeUnit = 0)
+ nextpaydate <- dealdata$"Deal Next Pay Date"
+ ## "Deal Next Pay Date" might be stale in the database
+ if(dealdata$"Deal Next Pay Date" < settledate){
+ prevpaydate <- nextpaydate
+ nextpaydate <- advance(calendar = calstring,
+ dates = nextpaydate,
+ n = 3,
+ timeUnit = 2)
+ }else{
+ prevpaydate <- advance(calendar = calstring,
+ dates = nextpaydate,
+ n = -3,
+ timeUnit = 2)
+ }
dates <- seq(prevpaydate, dealdata$maturity + lag, by=freq)
- dates <- dates[dates>startdate]
+ dates <- dates[dates>settledate]
return( dates )
}