How to output interest rates path with QuantLib Black Karasinski model?

27 Views Asked by At

Im trying to implement BLack Karasinski model in Python from scratch, and as an representative example I use QuantLib.

So, the problem is, that calibration can be done in both, C++ and Python, while simulating path of the interest rates is not available in Python.

Here's QL implementation of BK mode:

class BlackKarasinski : public OneFactorModel,
                            public TermStructureConsistentModel {
      public:
        BlackKarasinski(Handle<YieldTermStructure> termStructure,
                        Real a = 0.1, Real sigma = 0.1);

        ext::shared_ptr<ShortRateDynamics> dynamics() const override;

        ext::shared_ptr<Lattice> tree(const TimeGrid& grid) const override;

      private:
        class Dynamics;
        class Helper;

        Real a() const { return a_(0.0); }
        Real sigma() const { return sigma_(0.0); }

        Parameter& a_;
        Parameter& sigma_;
        Parameter phi_;
    };

I have found BlackKarasinski::Dynamics, and Im trying to get short rates as :

auto test = modelBK.get()->dynamics().get()->shortRate(3,0.05);  

by using BermudanSwaption example project, but it gives me error

fitting parameter not set!

So, how do I get BK simulation from QuantLib?

0

There are 0 best solutions below