Skip to content
All library documents

Learning QuantLib Python and Finding Its Available Features

Article Quant Q&A · Author: hopflink

Summary

The discussion addresses how a Python user can learn QuantLib well enough to calculate derivatives such as an up-and-out call delta using a volatility surface. The accepted answer explains that Python largely follows the C++ library’s structure, with adaptations for Python conventions, so C++ documentation and examples can often guide Python use. However, not every library feature is exposed in Python, and the answer suggests checking the SWIG interface when uncertain whether a feature is available.

The replies point learners toward tutorials, screencasts, a Python cookbook, module reference material, and a general QuantLib guide. These resources are described as useful but, in some cases, incomplete or still in progress. The discussion does not provide a learning sequence or explain how to implement the specific barrier-option delta calculation. Its practical guidance is therefore about navigating documentation and verifying Python bindings, rather than teaching option pricing or validating a particular calculation.

Key ideas

  • QuantLib Python follows much of the C++ library’s structure, though some details are adapted for Python.
  • C++ documentation and examples can help Python users understand library concepts and workflows.
  • Not every QuantLib feature is necessarily exposed through the Python bindings.
  • SWIG interface files can be checked to determine whether a feature is available in Python.
  • Tutorials, screencasts, cookbooks, and reference guides offer learning material, though coverage may be incomplete.

Tags

Full text
# How to learn QuantLib-python at first?


# How to learn QuantLib-python at first?












In my project, I have to get the delta of up and out call option (with vol surface). I found out that QuantLib might help me on that. Since my main language is python and I don't know well about C++, I installed QuantLib-python, in the hope that python is enough to understand QuantLib. But I couldn't find a well-written documentation about QuantLib-Python. I managed to understand some sources in blog posts, like calculating vanilla call option price. I now think that to do what I want to do, I have to understand the C++ sources in QuantLib. Am I right? Or Would there a better and faster way?

## Answer by Luigi Ballabio (score 17, accepted)

https://quant.stackexchange.com/a/19077

At this time, there's no specific documentation for QuantLib-Python, except for a series of screencasts that I started a while ago (you can find them on YouTube at https://www.youtube.com/playlist?list=PLu_PrO8j6XAvOAlZND9WUPwTHY_GYhJVr) but which is far from exhaustive; there's just a few of them for now, and there's no definite learning path.

However, the structure of the library in Python is the same as in C++, except for some changes (like the use of `std::shared_ptr` in C++ being hidden in Python) that were made so that one could write more idiomatic Python code. Therefore, you should be able to use the resources listed on the QuantLib site at http://quantlib.org/docs.shtml and translate their advice to the corresponding Python code.

One thing you might run into is that not all of QuantLib is exported to Python. Again, there's no documentation of what's there; so when in doubt, search for a feature inside the SWIG interface files to check if it's exported.

Update: last year, Goutham and I have pooled our material and published the QuantLib Python Cookbook. It's still a work in progress, but it might already be useful.

Further update: as of the end of 2024, A QuantLib Guide is also available.

## Answer by Goutham (score 11)

https://quant.stackexchange.com/a/21672

You will find a tutorial of QuantLib using python with simple examples here:

http://gouthamanbalaraman.com/blog/quantlib-python-tutorials-with-examples.html

I have been writing these as a means to be instructive to others going through the process of learning and working with QuantLib. If you have suggestions on what topics you would like to read, please post a comment.

## Answer by Kirill Dolmatov (score 4)

https://quant.stackexchange.com/a/25421

I also recommend to see: https://ipythonquant.wordpress.com/ There are some good examples.

## Answer by 徐瑞龙 (score 2)

https://quant.stackexchange.com/a/49164

For Chinese user, you can find a tutorial of QuantLib using python and C++:

https://www.cnblogs.com/xuruilong100/p/8711520.html

## Answer by David Duarte (score 2)

https://quant.stackexchange.com/a/51492

You can check out a reference to the QuantLib-Python module at:

https://quantlib-python-docs.readthedocs.io

It's still a work in progress but will be very helpful for anyone getting started

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.