Skip to content
Matthew Son edited this page Sep 18, 2021 · 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")

Mac OSX (Sierra) (Big Sur)

  1. Open the terminal, where you need to execute the commands;
  2. Install Homebrew, so that you can use Homebrew to manage packages on OSX:
    /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  3. 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;
  4. brew install quantlib --with-intraday to install the pre-built binary version of QuantLib with intraday feature;
  5. quantlib-config --version to check your QuantLib version;
  6. If the version of QuantLib is lower than 1.9.1, you need to do an extra job that is to add five inline in multicurvesensitivities.hpp, see https://github.com/lballabio/QuantLib/pull/161. You can edit the file via sudo vi /usr/local/include/ql/experimental/termstructures/multicurvesensitivities.hpp;
  7. brew link quantlib to create the symbolic link for QuantLib, in case of failing to link automatically;
  8. (In R console)install.packages("RQuantLib", configure.args = "--with-boost-include=/usr/local/include/ --with-boost-lib=/usr/local/lib/", type = "source") to install RQuantLib packages from source.

Note:

brew install quantlib --with-intraday no longer works, but brew install quantlib includes intraday feature currently #141 (Checked at 2021-09-18)

If you encounter compiling error with install.packages("RQuantLib", configure.args = "--with-boost-include=/usr/local/include/ --with-boost-lib=/usr/local/lib/", type = "source"), try disabling your Makevars to use apple-default compliers.

If you want to install QuantLib from the source, please look up the instruction here. Be careful, when using Homebrew to install, you need to replace all the /opt/local/ in the instruction with /usr/local/.

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