Skip to main content
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
13 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
13 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
  • 3,036
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
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,825
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
8 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,825
8 votes
Accepted

Quantlib: day-by-day evaluation of option value

There are two different time gaps in OVML: time to expiry = Expiry Date - Price Date time to delivery = Delivery Date - Premium Date You can see the premium date at the bottom of the OVML screen. ...
AKdemy's user avatar
  • 8,989
8 votes
Accepted

Recommended Setup for QuantLib-Python AmortizingFloatingRateBond

A few things before creating the bond: 1) You can delegate to the library the calculation of the dates. Your code is equivalent to: ...
Luigi Ballabio's user avatar
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

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,825
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
  • 12.2k
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,265
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,265
6 votes

Pricing a fixed rate bond in Quantlib Python

try: dayCount = ql.ActualActual(ql.ActualActual.ISMA,schedule)
bn_ln's user avatar
  • 161
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

QuantLib returns slightly different bondYield when backtested

I would start by saying that yes, this is an acceptable precision. However, the reason you are not getting the same result is because, by default, QuantLib has ...
David Duarte's user avatar
  • 5,825
6 votes
Accepted

how can i see the cashflows of a specific bond created in quantlib in Python? this is the code i have, how should i change it

As Dimitri said, you can use the cashflows inspectors: for cf in bond.cashflows(): print(cf.date().ISO(), cf.amount()) 2019-07-30 1.4999999999999902 2020-01-30 ...
David Duarte's user avatar
  • 5,825
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,825
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,825
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,825
5 votes

Constructing yield curve directly from yield-to-maturity data

Unless all of your yields are par yields (yield of bonds trading at par), you'll get very unreliable results if you fit your curve using yields alone. This is because yields can be distorted by the ...
Helin's user avatar
  • 11.7k
5 votes

How to build a cross currency swap pricer?

I recenlty worked on a similar problem and solved it with the help of Quantlib library. Assuming you are working with EUR and USD: get cross currency (xccy) swap data EUR / USD. You want to know how ...
Bozothegrey'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
5 votes

Discounting Curve in Quantlib/Python

You can use the DiscountCurve class, that takes a list of dates and a list of corresponding discount factors. The one exported by default in the Python module uses ...
Luigi Ballabio's user avatar
5 votes

Excel YIELD function equivalent in python Quantlib

Your question is more or less answered in How to calculate bond yield in QuantLib - Python. Once you've built the fixed-rate bond object (as in the post you linked) you can call ...
Luigi Ballabio's user avatar
5 votes
Accepted

Use QuantLib Python to calculate roll-down of a swap

No, I think you're getting a wrong figure. The general idea might work, but the construction of the second swap must be changed. (Or you can use just one swap; I'll get to that later.) As I read ...
Luigi Ballabio's user avatar

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