Exposing CallableFixedRateBond to QuantLibXL: how to use ShortRateModel instead of AffineModel
Posted by
Lisa Ann on
Sep 24, 2015; 10:04am
URL: http://quantlib.414.s1.nabble.com/Exposing-CallableFixedRateBond-to-QuantLibXL-how-to-use-ShortRateModel-instead-of-AffineModel-tp16923.html
I've followed
this great tutorial and it worked; furthermore, I've exposed AmortizingFixedRateBond, AmortizingFloatingRateBond and AmortizingCmsRateBond, and they worked fine.
Now would like to expose a simple "wrapper" for CallableFixedRateBond, but I'm likely stuck with a design problem.
My idea is to extend
QuantLibAddin\qlo\bonds.hpp and
QuantLibAddin\qlo\bonds.cpp: declaration in the former should not require anything more than almost the same constructor used by FixedRateBond (plus
const std::vector<QuantLib::Real>& callPrices, const
std::vector<QuantLib::Real>& callDates and
const boost::shared_ptr<QuantLib::ShortRateModel>& shortRateModel), implementation in the latter, on the contrary, is giving some issues.
Declaration:
#include <qlo/shortratemodels.hpp> and
#include <ql/models/shortrate/onefactormodel.hpp> should allow to use
const boost::shared_ptr<QuantLib::ShortRateModel>& shortRateModel in constructor declaration... correct?
Implementation: here are some issues.
#include <ql/experimental/callablebonds/callablebond.hpp>,
#include <ql/experimental/callablebonds/treecallablebondengine.hpp> and
#include <ql/instruments/callabilityschedule.hpp> are needed, of course.
The main issue is:
C:\build_ql_1_6_0\QuantLibAddin\gensrc\metadata\types\types.xml has only AffineModel as libraryClass, whilst QuantLib::TreeCallableFixedRatebondEngine class wants a
const boost::shared_ptr<ShortRarteModel>. Here we come to
C:\build_ql_1_6_0\QuantLibAddin\gensrc\metadata\functions\bonds.xml: the only parameter different than other bonds' ones is the short rate model id. My guess:
<Parameter name='ShortRateModel'>
<type>QuantLib::AffineModel</type>
<superType>libraryClass</superType>
<tensorRank>scalar</tensorRank>
<description>Short rate model ID.</description>
</Parameter>Nevertheless, I cannot use QuantLib::AffineModel type here because QuantLib::TreeCallableFixedRatebondEngine wants a
boost::shared_ptr<ShortRarteModel>.
Any solution to use QuantLib::AffineModel as type but actually QuantLib::ShortRateModel as template for the boost::shared_ptr which I will pass to QuantLib::TreeCallableFixedRatebondEngine?