eddelbuettel / rquantlib

R interface to the QuantLib library
119 stars 50 forks source link

Wrong count of business days for Brazil #152

Closed GitHunter0 closed 4 years ago

GitHunter0 commented 4 years ago

This function is returning 7 days when it should return 4, it is even counting the weekend days.

RQuantLib::businessDaysBetween(
  calendar="Brazil",
  from=as.Date("2020-09-06"), to=as.Date("2020-09-12"),
  includeFirst = TRUE, includeLast = TRUE)

I appreciate if you can assess the issue.

eddelbuettel commented 4 years ago

What version of RQuantLib are you running? Against which version of QuantLib?

I get a different value here -- RQuantLib 0.4.12 using QuantLib 1.19"

R> library(RQuantLib)
R> businessDaysBetween(calendar="Brazil",  from=as.Date("2020-09-06"), to=as.Date("2020-09-12"), 
                                           includeFirst = TRUE, includeLast = TRUE)
[1] 4
R> 
GitHunter0 commented 4 years ago

I'm running the same version. I executed the code several times to make sure the result was indeed 7. However, something might have caused conflict on RQuantLib package because, now that I restarted my R session, the result is correct, 4. I'm glad it is working as expected now, it is a very useful package. Thank you very much