Skip to content
All library documents

Accessing Hull–White Trees and Lattices in QuantLib

Article Quant Q&A · Author: ctrl-alt-delete

Summary

The question concerns constructing a trinomial tree for the Hull–White interest-rate model in QuantLib, identifying the relevant API, and inspecting the tree used by a swaption pricing engine. The answer points to the model’s tree method as the route to obtaining a lattice, with the user specifying the time grid. It also notes that the Hull–White constructor can take a term structure together with mean-reversion and volatility parameters.

The returned lattice abstraction provides operations such as rollback, which propagates a discretized asset’s value backward through the grid to support instrument pricing. The response directs readers to QuantLib’s lattice documentation for fuller guidance. It does not explain how to visualize or print the tree, establish what tree a particular engine selects, or provide a complete Python example, so those parts of the original question remain unresolved.

Key ideas

  • The Hull–White model exposes a method for obtaining a lattice after the model is constructed.
  • The lattice requires a chosen time grid for its construction.
  • Hull–White parameters can include mean reversion and volatility alongside the term structure.
  • The lattice rollback operation propagates a discretized asset backward to support pricing.
  • The answer does not specify how to visualize the tree or confirm the engine’s selected tree type.

Tags

Full text
# How to construct interest rate trinomial tree for Hull-White model using QuantLib and Python


# How to construct interest rate trinomial tree for Hull-White model using QuantLib and Python












I need to construct a Trinomial Tree for Hull-White model. Looking at the docs:

http://quantlib.org/reference/modules.html

or http://quantlib.org/reference/search.php?query=Trinomial

I see many modules or members that match trinomial.

How would I know which to use?

Or if I do something like:

```
model = HullWhite(term_structure);
```

How would I know if the `TreeSwaptionEngine` has selected a Trinomial tree and is it possible to print the tree or visualize with Graphviz?

I've looked at the examples here but it is still not obvious how these map back to the C++

## Answer by SmallChess (score 2, accepted)

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

Note: you can specify the mean reversion level and volatility for your HullWhite model with

> model = HullWhite(term_structure, my_level, my_sigma);

Once you establish your model with the `HullWhite` constructor, there is a method you can use:

Do you see the `tree` method? You will need to specify what grid you want for your lattice. The implementation for the method looks like what you're looking for:

The method returns a pointer to `Lattice`. It defines the following methods:

```
virtual void rollback(DiscretizedAsset&, Time to) const = 0;
```

This method rolls back the tree to your present date, and thus price your instrument. Please take a look at the section about Lattice in Luigi Ballabio's QuantLib book. It teaches you how to deal with lattice in QuantLib.

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.