Quantlib is a C++ library that aids writing software for quantitative finance. Since it was first released in November 2000 it has continuously grown in popularity in the financial industry. QuanLib is an open source project. This has many advantages. First of all, it is free. There is no cost involved in using the library and developing your own software with it. Because many people use the software, it is also thoroughly tested. In general, open software tends to have less bugs than restricted commercial software. This is due to the collective intelligence of all the users and developers. Any errors are quickly found and corrected. Finally, it is easy to extend. Because the source code is freely available the developer can learn from the implementation of its functionality. Parts of can be used as a template for any extensions that need to be added.
One downside of open source software is usually the relatively poor documentation. Because developers of open source software like to develop the code, and they don’t much like to write the manuals, the documentation is usually quickly done or left for later. QuantLib is no exception here.
This is where this series of posts comes in. In the coming year I will write manuals and tutorials for the usage of QuantLib. In time this should provide a comprehensive documentation about the library and its usage.
QuantLib makes use of the boost library. Knowing the ins and outs of boost also makes it easier to write more concise code with QuantLib. Where appropriate this manual will take little detours introducing boost concepts.
QuantLib is organised into modules. Each module covers a specific aspect of the library’s functionality and contains a set of functions, classes, or sometimes just a collection of macros and typedefs.
At the time of writing, the list of modules on the QuantLib reference pages was not up to date with the 1.2 release of the code. Here is the complete list of modules which I have attempted to extracted from the source code.
A number of numeric types are defined in order to add clarity to function and method declarations.
Global definitions and a few macros which help porting the code to different compilers.
Various utility classes. Stepping iterators that have go through an underlying container in larger strides, a disposable wrapper for returning expensive-to-copy objects by value, and data formatters and parsers.
Currencies and FX rates
Classes storing currency information and handling exchange rates between currencies. Contains many predefined national currencies.
C++ template implementations of some software design patterns used in the QuantLib library
Date and time calculations
Classes for handling dates, calendars and calculations with dates. Also provides a collection of pre-defined calendars and day counters.
Pseudo random number generators, root finding algorithms, and optimisation methods.
This framework contains basic building blocks for the numerical solution of partial differential equations by means of finite-difference methods.
Building blocks for implementing pricing calculations using lattice methods. Lattices rely on one or several trees (each one approximating a diffusion process) to price an instance of the DiscretizedAsset class.
Monte Carlo framework
This framework contains basic building blocks for Monte Carlo simulations.
Classes and functions for working with cash flows and sequences of cash flows. Different types of cash flows are pre-defined.
Framework for defining yield term structures. Some adapter classes provide implementations of frequently used methods and only the non-redundant parts need to be completed. Many pre-defined term structures are defined.
Classes for storing historical fixings of different index types. Time series can be created from the fixing data.
Classes for calculating quotes from underlying indexes.
Highly flexible framework for pricing financial claims. Pricing engines can be constructed by individually specifying the contract, the risk factors and their dynamics, and the calculation method for the expected discounted value. Contains many predefined engines.
Defines a collection of financial instruments. These can be evaluated using different pricing engines.
A collection of some market models and a framework supporting the implementation of other models.
Short-rate modelling framework
This framework implements some single-factor and two-factor short rate models which are widely used by practitioners.
Some classes implementing different volatility models.
A framework implementing a variety of stochastic processes. These processes can be plugged into various models and pricing engines.
Modules can be included via the include directive. The header file for each module is also specified in the above list. Some individual classes have their own header files and these can be included if you don’t want to include the whole module. Alternatively, if you don’t care about the individual packages, you can just include “quantlib.hpp” at the top of your document to include all the modules.
All the classes and typedefs live in the Quantlib namespace. In the tutorials I will assume that the following line is placed at the top of every source code example.
using namespace QuantLib;
- Programming Tools
- Dates and Calendars
- Mathematical Tools
- Finance Basics
- Cash Flows
- Term Structures
Tagsbasics c++ calendars cashflow control statements coupons currencies data structure dates day counters design pattern dividend events exceptions exchange rates grammar if indices instrument introduction java macros Manual money observable observer parser periods quantlib quotes recursive descent term structure time series tips tokenizer tracing tree tutorial typedefs visitor