13 votes
Accepted

Why does it take so many lines of code to price even the simplest of options with QuantLib

I've been using QuantLib for quite a while. Let me share some experience: QuantLib is a highly sophisticated quantitative framework. It can do much and much more than a simple pricing of European ...
SmallChess's user avatar
  • 2,255
13 votes
Accepted

Simple QuantLib Bond Math

To begin with, as Student T suggested, you can check that the cashflows are those you expect: ...
Luigi Ballabio's user avatar
12 votes
Accepted

Use QuantLib Python to calculate Swap DV01

No, I'm afraid you're comparing apples with oranges. Your calculation of the DV01 of the swap is correct (with a caveat, see below), but the figure returned from ...
Luigi Ballabio's user avatar
12 votes

Mixed local-stochastic volatility model in Quantlib

Stochastic-Local Vol (SLV) is an attempt to mix the strengths and weaknesses of both Stochastic Vol and Local Vol models. Below, I'll quickly summarise each model and their strengths and weaknesses, ...
StackG's user avatar
  • 2,996
10 votes
Accepted

Quantlib python dual curve bootstrapping example

I reproduce the Ametrano-Bianchetti paper on dual-curve bootstrapping in Python with QuantLib in a chapter of the QuantLib Python Cookbook. (Note: I'm not sure what the etiquette is about plugging ...
Luigi Ballabio's user avatar
9 votes

What is the best alternative of Quantlib library

The Strata project is the new pure Java market risk quant library from OpenGamma. For more information, see the documentation and GitHub. It is Apache v2 licensed. Strata takes the experience of the ...
JodaStephen's user avatar
9 votes
Accepted

SABR Model Pricing Engine in Python QuantLib

Here is a simple example that might be useful. Basically finding parameters for a given section. Some of the parameters might be assumed at start instead of calibrated. ...
David Duarte's user avatar
  • 5,685
8 votes

How to learn QuantLib-python at first?

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 ...
Goutham's user avatar
  • 206
8 votes
Accepted

AmericanOptionImpliedVolatility - root not bracketed issue in QuantLib/R

It is a simple root finder, and if you give it impossible starting values... well then it fails. Here, you can play with the values and it seems bounded at USD 5 whereas you start from USD 2.7: <...
Dirk Eddelbuettel's user avatar
8 votes
Accepted

How to calculate bond yield in QuantLib - Python

In the call to Bisection.solve, the question mark must be the Python function whose zero you want to find. In your case, it should be something reproducing the ...
Luigi Ballabio's user avatar
8 votes
Accepted

Issue Using QuantLib and Python to Calculate Price and Greeks for American Option With Discrete Dividends

You're not setting the global evaluation date. If you don't, you're in December 2017 and your option has expired a good while ago. Adding ...
Luigi Ballabio's user avatar
8 votes
Accepted

Multithreading Monte-Carlo pricing in QuantLib for a single product

Yes, it can work. However, keep in mind that: you'll be safer if you don't share any objects between threads; see my answer here, in particular the last point; even if you use different seeds, there'...
Luigi Ballabio's user avatar
7 votes

How to select the initial guess for implied volatility?

It is always better to use some closed form approximation first to get initial guess. Corrado and Miller (1996) produced a solution that is quite accurate across a range of moneyness ( though it can ...
Neeraj's user avatar
  • 2,218
7 votes
Accepted

Quantlib-Python: use zero rates to get the originally bootstrapped curve

To retrieve the original curve, you need to use the same key tenors of the original curve and with the same interpolation. For instance, when you create the original curve as: ...
Luigi Ballabio's user avatar
7 votes
Accepted

Bootstrapping OIS curve

I see several problems that might explain those differences: The frequency of the fixed leg on a EONIA swap is Annual and not semi The deposit facility rate is not part of the EONIA curve. Use the ...
David Duarte's user avatar
  • 5,685
6 votes

How to select the initial guess for implied volatility?

Do you really need to do this yourself? The absolute state of the art is Peter Jaeckel's work, where he makes an implied vol function as good as exp, cos, and log special functions. And he ...
q.t.f.'s user avatar
  • 1,875
6 votes

What is the best alternative of Quantlib library

I did not tested it by now, but Google released a library similar to quantlib written in TensorFlow (tf-quant-finance). It may be worthwhile to test it (and to post here your views on it), because ...
lehalle's user avatar
  • 11.5k
6 votes
Accepted

Quantlib bootstraping fails on 5y swap

You're not the first to trip on this, and unfortunately the fact that the provided example is from a different era doesn't help. Quite simply, you're not writing rates correctly. The 5-years swap ...
Luigi Ballabio's user avatar
6 votes

Why does it take so many lines of code to price even the simplest of options with QuantLib

And don't forget that there are wrappers as eq RQuantLib which I use on the command-line here: ...
Dirk Eddelbuettel's user avatar
6 votes
Accepted

How do you check your option calculations?

1: Follow the calculations in The Complete Guide to Option Pricing Formulas. The book has many formulas, sample values and outputs. Highly recommended for validating your results. Apparently, this is ...
SmallChess's user avatar
  • 2,255
6 votes
Accepted

QuantLib Gsr model

the model is described in Andersen, Piterbarg: Interest Rate Modeling. The formulas that are acutally implemented are derived here https://ssrn.com/abstract=2246013 Best Peter
Peter Caspers's user avatar
6 votes

Install QuantLib on Mac OS X

I use Xcode for QuantLib. It works great. To compile the project, just put all the source files into the Xcode project like: That's the C++ compiler I use: That's how I configure my header files. ...
SmallChess's user avatar
  • 2,255
6 votes

What are the best [free]resources to learn C++ particularly for quantitative finance?

I think it's best to learn generic C++. Most of the firms hiring for quant Dev roles usually need good general programming skills and interest in the markets. If you're learning for personal trading I'...
Dhruv Mahajan's user avatar
6 votes
Accepted

FX Forward rate agreement valuation in quantlib

You are not giving the constructor a discountCurve. The constructor is: ...
David Duarte's user avatar
  • 5,685
6 votes
Accepted

Bootstrap with QuantLib: Fair Swap or zero NPV

The problem is that you are not pricing the same thing, and for two reasons: The vanilla instruments you are pricing should start on spot date and have a maturity with that start as reference The ...
David Duarte's user avatar
  • 5,685
6 votes

Bond portfolio valuation in Quantlib python

QuantLib doesn't really have the concept of portfolio but since you're using pandas, you can play around with that to price your bonds at once. Here is an example: ...
David Duarte's user avatar
  • 5,685
6 votes
Accepted

Explanation for Different Piecewise Yield Term Structures from QuantLib Python

When you bootstrap a curve, you get discount factors/zero rates for the maturities of the instruments you supplied. So in practice, you get points, and not a "curve". After you have built ...
David Duarte's user avatar
  • 5,685
6 votes
Accepted

Quantlib: day-by-day evaluation of option value

The language below is not Python, but Julia because I already had this code. However, the syntax is sufficiently similar to Python so it should be possible to follow the logic. I replicate both ...
AKdemy's user avatar
  • 8,143
5 votes

Why does it take so many lines of code to price even the simplest of options with QuantLib

To add to Student T's answer, which I second: the complex setup starts making sense (and its cost gets amortized) once you start keeping the instruments around instead of throwing them away after the ...
Luigi Ballabio's user avatar
5 votes
Accepted

How many ways can QuantLib handle the price of option on its maturity date?

As you saw, the default behavior is to consider the option expired at the exercise date, so the NPV is null. You can override this behavior by executing ...
Luigi Ballabio's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible