About QuantLib

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 Modules

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.

Numeric types
#include <ql/types.hpp>
A number of numeric types are defined in order to add clarity to function and method declarations.

QuantLib macros
#include <ql/qldefines.hpp>
Global definitions and a few macros which help porting the code to different compilers.

#include <ql/utilities/all.hpp>
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
#include <ql/currencies/all.hpp>
Classes storing currency information and handling exchange rates between currencies. Contains many predefined national currencies.

Design patterns
#include <ql/patterns/all.hpp>
C++ template implementations of some software design patterns used in the QuantLib library

Date and time calculations
#include <ql/time/all.hpp>
Classes for handling dates, calendars and calculations with dates. Also provides a collection of pre-defined calendars and day counters.

Math tools
#include <ql/math/all.hpp>
Pseudo random number generators, root finding algorithms, and optimisation methods.

Finite-differences framework
#include <ql/methods/finitedifferences/all.hpp>
This framework contains basic building blocks for the numerical solution of partial differential equations by means of finite-difference methods.

Lattice methods
#include <ql/methods/lattices/all.hpp>
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
#include <ql/methods/montecarlo/all.hpp>
This framework contains basic building blocks for Monte Carlo simulations.

#include <ql/cashflows/all.hpp>
Classes and functions for working with cash flows and sequences of cash flows. Different types of cash flows are pre-defined.

Term structures
#include <ql/termstructures/all.hpp>
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.

#include <ql/indexes/all.hpp>
Classes for storing historical fixings of different index types. Time series can be created from the fixing data.

#include <ql/quotes/all.hpp>
Classes for calculating quotes from underlying indexes.

Pricing engines
#include <ql/pricingengines/all.hpp>
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.

Financial instruments
#include <ql/instruments/all.hpp>
Defines a collection of financial instruments. These can be evaluated using different pricing engines.

Equity Models
#include <ql/models/equity/all.hpp>

Market Models
#include <ql/models/market/all.hpp>
A collection of some market models and a framework supporting the implementation of other models.

Short-rate modelling framework
#include <ql/models/shortrate/all.hpp>
This framework implements some single-factor and two-factor short rate models which are widely used by practitioners.

Volatility Models
#include <ql/models/volatility/all.hpp>
Some classes implementing different volatility models.

Stochastic processes
#include <ql/processes/all.hpp>
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;
Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>