[R-SIG-Finance] RQuantLib Holiday Calendar

Charles Duranceau cduranceau at nial.ky
Wed Sep 7 19:33:55 CEST 2016


Hi,
Is there a way to modify/update or create a holiday calendar in RQuantLib?

The reason I'm asking is that having pre-defined, hard-coded, holiday calendars maybe convenient but is limited as it does not cover all countries and will omit a possible change in the future.
More importantly it fell short to represent financial reality by restricting the use to only one calendar (not combined or unified) while in some instance more than one calendar need to be taken into account.


*         In Forex market, settlement calendar required that the financials centers related to the countries of the currency being  open and, for a cross currencies instrument, required that US banking being open.


*         For single currency (non GBP), interest rate swap where the fixing is based on Libor, the banks of the country related to the settlement the currency and London bank need to be open which require a combined calendar.

In the following example (see bottom for code)  I showed that a US 5Y swap starting on August 31 2016 will have a wrong date (2020-08-31) when using the US default calendar but will have the right date when using the "UK" calendar because of a holiday on 2020-08-31 which bring back the date to 2020-08-28.

This lead to a wrong generation of date schedule and thus cash flows hence impacting valuation and calibration.

I add a look and Quanlib which suggest using ql/time/calendars/bespokecalendar.hpp but I don't think it's possible in RQuantlib.
Is there any idea to combined or customized holiday calendar in RQuantLib?

I don't know if these rules are expressed in any decent Finance textbook as they are market conventions but think they could be useful to know

Regards
Charles


Code to replicate
Example with US calendar only => wrong date
params <- list(effectiveDate=as.Date("2016-08-31"),
+                maturityDate=as.Date("2021-08-31"),
+                period='Semiannual',
+                calendar="UnitedStates",
+                businessDayConvention=1,
+                terminationDateConvention=1,
+                dateGeneration='Backward',emr =0)


Schedule(params)

 [1] "2016-08-31" "2017-02-28" "2017-08-31" "2018-02-28" "2018-08-31" "2019-02-28"

 [7] "2019-08-30" "2020-02-28" "2020-08-31" "2021-02-26" "2021-08-31"

Example with UK calendar only => good schedule but not general as it need to include US holidays as well

params <- list(effectiveDate=as.Date("2016-08-31"),

+                maturityDate=as.Date("2021-08-31"),

+                period='Semiannual',

+                calendar="UnitedKingdom",

+                businessDayConvention=1,

+                terminationDateConvention=1,

+                dateGeneration='Backward',emr =0)

> Schedule(params)

 [1] "2016-08-31" "2017-02-28" "2017-08-31" "2018-02-28" "2018-08-31" "2019-02-28"

 [7] "2019-08-30" "2020-02-28" "2020-08-28" "2021-02-26" "2021-08-31"


Charles



**********************************************************************************************************************************************************
The contents of this email and any attachments are confidential to the intended recipient.  They may not be disclosed to or used by or copied in any way by anyone other than the intended recipient.  If this email is received in error, please contact Northview Investment Advisors Ltd. on + 1 345 943 2828 quoting the name of the sender and the email address to which it has been sent and then delete it.

Please further note that neither Northview Investment Advisors Ltd. nor the sender accepts any responsibility for viruses and it is your responsibility to scan or otherwise check this email and any attachments


	[[alternative HTML version deleted]]



More information about the R-SIG-Finance mailing list