Skip to content
Matthew Son edited this page Sep 10, 2024 · 10 revisions

Background

RQuantLib is an R interface to the C++ library QuantLib. Currently, no binary packages of RQuantLib are being provided by CRAN. So users typically need to install QuantLib in order to compile RQuantLib from source, and then run it.

NB:

  1. It may take considerable time (_i.e., possibly several hours) to compile QuantLib from source. Thus, we recommend to install binary version directly if it is possible.
  2. RQuantLib refers to the R package, while QuantLib refers to the C++ Quantitative library that RQuantLib uses. Please do not confuse the two terms.

Windows

Starting with release 0.4.3, binaries of RQuantLib (including the required QuantLib object) are provided via the ghrr drat repo and can be installed in an R session with the following commands:

if (!require("drat")) install.packages("drat")
drat::addRepo("ghrr")
install.packages("RQuantLib", type="binary")

MacOS

  1. Ensure that Apple’s Command Line Tools for Xcode (which includes clang) are installed.
  2. Open the terminal, where you need to execute the commands;
  3. Install Homebrew, so that you can use Homebrew to manage packages on OSX:
    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  4. brew install boost to install boost (a C++ library needed by QuantLib). You might need to accept the license of XCode or install XCode, just follow the message that pops up in the terminal;
  5. In R console, install with
install.packages(
  "RQuantLib", 
  type = "source",
  configure.args = 
    c("--with-boost-include=/opt/homebrew/opt/boost/include/"),
  configure.vars = 
    c("CPPFLAGS='-DQL_HIGH_RESOLUTION_DATE'") # for intraday calculations
)

Note:

brew install quantlib --with-intraday no longer works, and it does not come with the intraday feature anymore. You need to install quantlib with custom configuration -DQL_HIGH_RESOLUTION_DATE for cmake.

Debian and Ubuntu

Simply sudo apt-get install r-cran-rquantlib installs the RQuantLib package for R. If you want the headers and examples of QuantLib as well, please execute sudo apt-get install r-cran-rquantlib quantlib-examples libquantlib0-dev.

Other platforms

  1. Check out http://quantlib.org/install.shtml to install QuantLib;
  2. Install RQuantLib using install.packages() or R CMD INSTALL.
Clone this wiki locally