I want to bootstrap a yield curve in Python using QuantLib library. I know that when doing bootstrapping using C++, there is a function for bootstrapping called PiecewiseYieldCurve in QuantLiab, but when I am using Python, there is no such function in Python QuantLib. I wonder that if in Python QuantLib there is an alias of PiecewiseYieldCurve, so I have to call the alias function name in order to use PiecewiseYieldCurve function
Should I creating my own function to bootstrap the yield curve?
Thanks!
PiecewiseYieldCurve
is a class template, so it can't be exported to Python as such. By default, we're exporting to Python a particular instantiation of it; it's exported as PiecewiseFlatForward
and it correspond to PiecewiseYieldCurve<ForwardRate,BackwardFlat>
.
If you need another instantiation, you can edit QuantLib-SWIG/SWIG/piecewiseyieldcurve.i
, add it (it you look at the end of the file, you'll find a few examples of how to do it) and regenerate and recompile the Python wrappers.
Finally, an example of bootstrap is available in QuantLib-SWIG/Python/examples/swap.py
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.