# 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

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++

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.

• thanks, from this how would that translate to using in Quanlib_Python? Is there a pattern that should be followed to translate? Jan 26 '17 at 6:59
• @toasteez I'm sure there is one-to-one translation. If you see something in Python, it also appears in C++ under the same name. Jan 26 '17 at 7:00
• The tree method is not exported to Python. You can instantiate a Hull-White model and use it to price an instrument by passing it to the proper pricing engine, but there's no way to inspect the tree. For that, the needed interfaces should be added to the wrappers. Jan 27 '17 at 10:43
• @LuigiBallabio You mean FDM pricing engine? Jan 27 '17 at 10:44
• I mean an engine such as TreeSwaptionEngine, which takes a handle to a short-rate model. Jan 27 '17 at 10:45