Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring addHoliday() function to RQuantLib #115

Closed
pankaj3009 opened this issue Aug 22, 2018 · 4 comments
Closed

Bring addHoliday() function to RQuantLib #115

pankaj3009 opened this issue Aug 22, 2018 · 4 comments

Comments

@pankaj3009
Copy link

Quantlib has addHoliday()/removeHoliday() that adds/removes a "temporary" holiday to a calendar. However, i cannot find any such feature in RQuantLib. This will be very useful for users who install RQuantLib using the binary on Windows. Also, this function will provide functionality to implement adhoc holidays, without the need for time-consuming recompilation of Quantlib.

@pankaj3009 pankaj3009 changed the title Bring addHolidays() function to RQuantLib Bring addHoliday() function to RQuantLib Aug 22, 2018
@eddelbuettel
Copy link
Owner

That has come up in the past, and we decided against / said we cannot do it as you cannot easily persist the data from one session to the next.

Easier to do something locally:

  • use RQuantLib to extract holidays in favourite calendar
  • store them in a local file (or db)
  • add holidays to the file (or db)
  • look up holidays from local file (or db).

@pankaj3009
Copy link
Author

This is what i do currently but because the holidays are outside RQuantLib, I am unable to use any inbuilt calendar functions. For my use case, i am quite happy to reload holidays in RQuantLib at the start of each session.

I have not used QuantLib directly, but posts suggest that QuantLib will also not persist any changes via addHoliday() or removeHoliday() .

Please do reconsider if it makes sense. Thanks!

@eddelbuettel
Copy link
Owner

Adding interfaces to addHoliday() and removeHoliday() is pretty trivial -- they only operate on the currently-set calendar and do not persist.

I could add them, but not export them so you would need three colons to access them as an internal function.

@eddelbuettel
Copy link
Owner

It was quick enough so I added it:

> library(RQuantLib)
> thisweek <- Sys.Date() + -2:2
> thisweek
[1] "2018-08-20" "2018-08-21" "2018-08-22" "2018-08-23" "2018-08-24"
> isHoliday("TARGET", thisweek)
[1] FALSE FALSE FALSE FALSE FALSE
> addHolidays("TARGET", Sys.Date() + -1:1)
> isHoliday("TARGET", thisweek)
[1] FALSE  TRUE  TRUE  TRUE FALSE
> removeHolidays("TARGET", Sys.Date() + -1:1)
> isHoliday("TARGET", thisweek)
[1] FALSE FALSE FALSE FALSE FALSE
> 

Will commit in a moment.

eddelbuettel added a commit that referenced this issue Aug 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants