RcppQuantuccia

R Bindings for QuantLib Calendering

https://github.com/eddelbuettel/rcppquantuccia

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.9%) to scientific vocabulary

Keywords

cpp11 cran quantlib r-package
Last synced: 6 months ago · JSON representation

Repository

R Bindings for QuantLib Calendering

Basic Info
  • Host: GitHub
  • Owner: eddelbuettel
  • Language: C++
  • Default Branch: master
  • Homepage:
  • Size: 2.33 MB
Statistics
  • Stars: 13
  • Watchers: 5
  • Forks: 1
  • Open Issues: 2
  • Releases: 0
Topics
cpp11 cran quantlib r-package
Created almost 9 years ago · Last pushed 9 months ago
Metadata Files
Readme Changelog

README.md

RcppQuantuccia: Rcpp bindings for QuantLib Calendering

CI License CRAN Dependencies Downloads Last Commit

Status

Access to current calendaring functions from QuantLib in an easy-to-build smaller package.

As of release 0.1.0, all code is current to the current QuantLib release 1.24 (modulo a small patch set). All of the upstream, i.e. QuantLib, calendars are implemented as are the key access functions.

However, as Quantuccia upstream is stale, we now continue all future work in the qlcal organization on GitHub and its qlcal-r repo with the qlcal R package now also on CRAN. So this repository here will likely not see any future work.

Brief History

This package started as an integration of the (somewhat experimental) Quantuccia package (see next section) to R by means of Rcpp.

But Quantuccia did not continue beyond its initial proof of concept. As of release 0.0.5, we have now refocused it on an even smaller subset of QuantLib: just the calendaring. So code for pricers, math, models, schedules, ... that was in Quantuccia has been removed.

But the calendaring, along with all its support code, is now current with the current QuantLib release which, as of this writing, is 1.24.

So what is Quantuccia?

Quantuccia is the "little sister" of QuantLib: A header-only subset of which aims to provide the essential parts of QuantLib while being easier to deploy requiring only Boost headers besides itself. (Note that Quantuccia appears to no longer being developed in its upstream repo. However, the idea of only relying on Boost headers is brilliant and carried on here.)

Being header-only makes providing Quantuccia for R a breeze as we can rely on the Rcpp and BH packages. Nothing else is required, and as these packages are available on all relevant platforms, deploying RcppQuantuccia is straightforward.

Example

Here we examine holiday lists for given calendars, specified by country and possibly exchange:

r R> library(RcppQuantuccia) R> fromD <- as.Date("2017-01-01") R> toD <- as.Date("2017-12-31") R> getHolidays(fromD, toD) # default calender ie TARGET [1] "2017-04-14" "2017-04-17" "2017-05-01" "2017-12-25" "2017-12-26" R> setCalendar("UnitedStates") R> getHolidays(fromD, toD) # US aka US::Settlement [1] "2017-01-02" "2017-01-16" "2017-02-20" "2017-05-29" "2017-07-04" "2017-09-04" [7] "2017-10-09" "2017-11-10" "2017-11-23" "2017-12-25" R> setCalendar("UnitedStates::NYSE") R> getHolidays(fromD, toD) # US New York Stock Exchange [1] "2017-01-02" "2017-01-16" "2017-02-20" "2017-04-14" "2017-05-29" "2017-07-04" [7] "2017-09-04" "2017-11-23" "2017-12-25" R>

This shows the difference between the default US settlement calendar and the NYSE calendar which we selected explicitly.

As all calendars are now supported (and are listed in a convenience vector calendars):

```r

library(RcppQuantuccia) calendars [1] "TARGET" "UnitedStates" [3] "UnitedStates/LiborImpact" "UnitedStates/NYSE" [5] "UnitedStates/GovernmentBond" "UnitedStates/NERC" [7] "UnitedStates/FederalReserve" "Argentina" [9] "Australia" "Austria" [11] "Austria/Exchange" "Bespoke" [13] "Botswana" "Brazil" [15] "Brazil/Exchange" "Canada" [17] "Canada/TSX" "Chile" [19] "China" "China/IB" [21] "CzechRepublic" "Denmark" [23] "Finland" "France" [25] "France/Exchange" "Germany" [27] "Germany/FrankfurtStockExchange" "Germany/Xetra" [29] "Germany/Eurex" "Germany/Euwax" [31] "HongKong" "Hungary" [33] "Iceland" "India" [35] "Indonesia" "Israel" [37] "Italy" "Italy/Exchange" [39] "Japan" "Mexico" [41] "NewZealand" "Norway" [43] "Null" "Poland" [45] "Romania" "Russia" [47] "SaudiArabia" "Singapore" [49] "Slovakia" "SouthAfrica" [51] "SouthKorea" "SouthKorea/KRX" [53] "Sweden" "Switzerland" [55] "Taiwan" "Thailand" [57] "Turkey" "Ukraine" [59] "UnitedKingdom" "UnitedKingdom/Exchange" [61] "UnitedKingdom/Metals" "WeekendsOnly"

We can then for example quickly count number of holiday per calendar (by computing the length of the returned vector of holidays) and show a shortened print, all in a handful of lines continuing from above

```r

getHols <- function(cal) { # simple helper function + setCalendar(cal) + getHolidays(as.Date("2022-01-01"), as.Date("2022-12-31")) + } D <- data.table(calendar=calendars) D[ , :=(n = length(getHols(calendar)), + holidays = paste(format(getHols(calendar),"%d %b"), collapse=",")), + by = calendar ] D D calendar n holidays 1: TARGET 3 15 Apr,18 Apr,26 Dec 2: UnitedStates 10 17 Jan,21 Feb,30 May,20 Jun,04 Jul,05 Sep,10 Oct,11 Nov,24 Nov,26 Dec 3: UnitedStates/LiborImpact 10 17 Jan,21 Feb,30 May,20 Jun,04 Jul,05 Sep,10 Oct,11 Nov,24 Nov,26 Dec 4: UnitedStates/NYSE 9 17 Jan,21 Feb,15 Apr,30 May,20 Jun,04 Jul,05 Sep,24 Nov,26 Dec

5: UnitedStates/GovernmentBond 11 17 Jan,21 Feb,15 Apr,30 May,20 Jun,04 Jul,05 Sep,10 Oct,11 Nov,24 Nov,26 Dec

58: Ukraine 10 03 Jan,07 Jan,08 Mar,25 Apr,02 May,09 May,13 Jun,28 Jun,24 Aug,14 Oct 59: UnitedKingdom 9 03 Jan,15 Apr,18 Apr,02 May,02 Jun,03 Jun,29 Aug,26 Dec,27 Dec 60: UnitedKingdom/Exchange 9 03 Jan,15 Apr,18 Apr,02 May,02 Jun,03 Jun,29 Aug,26 Dec,27 Dec 61: UnitedKingdom/Metals 9 03 Jan,15 Apr,18 Apr,02 May,02 Jun,03 Jun,29 Aug,26 Dec,27 Dec 62: WeekendsOnly 0

```

Here we set the year to 2022 as it includes the added US holiday of Juneteenth.

We can also access the calendar 'name' from the underlying (QuantLib Calendar) object:

```r

D[, name := { setCalendar(calendar); getName() }, by=calendar][, .(calendar,name)] calendar name 1: TARGET TARGET 2: UnitedStates US settlement 3: UnitedStates/LiborImpact US with Libor impact 4: UnitedStates/NYSE New York stock exchange

5: UnitedStates/GovernmentBond US government bond market

58: Ukraine Ukrainian stock exchange 59: UnitedKingdom UK settlement 60: UnitedKingdom/Exchange London stock exchange 61: UnitedKingdom/Metals London metals exchange 62: WeekendsOnly weekends only

```

A Smaller Subset

As of version 0.0.3, we exclude the 7.6 mb header file sobolrsg.hpp, and well as references to it including the model subdirectory using the Sobol-based Brownian Market Models. This shrinks the resulting shared library from around 26 mb (!!) to 0.64 mb, and the (compressed) source tarball from 1.6 mb to 0.24 mb.

As of version 0.0.5, the focus is strictly on calendaring.

As of version 0.1.0, QuantLib files are included 'as is' (no longer converted to header-only as Quantuccia did) with a small (documented in a diff) set of changes essentially commenting out headers we no longer need and removed from some of the utilities directories, and turning off pragma instructions we are not allowed to use at CRAN.

Installation

The package can be installed from CRAN via

r install.packages("RcppQuantuccia")

or if you prefer non-release development version these can be installed from GitHub via e.g.

r remotes::install_github("eddelbuettel/rcppquantuccia")

or maybe just checkout the repository locally.

It only requires Rcpp and BH both of which are available whereever R itself runs.

Authors

Dirk Eddelbuettel for the package and integration

The authors and contributors of QuantLib for the underlying calendaring code

License

GPL (>= 2)

Owner

  • Name: Dirk Eddelbuettel
  • Login: eddelbuettel
  • Kind: user
  • Location: Chicago, IL, USA

GitHub Events

Total
  • Push event: 1
Last Year
  • Push event: 1

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 85
  • Total Committers: 1
  • Avg Commits per committer: 85.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 4
  • Committers: 1
  • Avg Commits per committer: 4.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Dirk Eddelbuettel e****d@d****g 85
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 7 months ago

All Time
  • Total issues: 3
  • Total pull requests: 9
  • Average time to close issues: about 2 hours
  • Average time to close pull requests: 11 minutes
  • Total issue authors: 3
  • Total pull request authors: 1
  • Average comments per issue: 4.0
  • Average comments per pull request: 0.11
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • petermeissner (1)
  • eddelbuettel (1)
  • shrektan (1)
Pull Request Authors
  • eddelbuettel (9)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 298 last-month
  • Total docker downloads: 21,777
  • Total dependent packages: 0
  • Total dependent repositories: 1
  • Total versions: 8
  • Total maintainers: 1
cran.r-project.org: RcppQuantuccia

R Bindings to the Calendaring Functionality of 'QuantLib'

  • Versions: 8
  • Dependent Packages: 0
  • Dependent Repositories: 1
  • Downloads: 298 Last month
  • Docker Downloads: 21,777
Rankings
Docker downloads count: 12.5%
Stargazers count: 16.5%
Forks count: 21.0%
Average: 23.8%
Dependent repos count: 23.8%
Dependent packages count: 28.6%
Downloads: 40.2%
Maintainers (1)
Last synced: 6 months ago

Dependencies

DESCRIPTION cran
  • Rcpp * imports
.github/workflows/ci.yaml actions
  • actions/checkout v3 composite