Exposing CallableFixedRateBond to QuantLibXL: how to use ShortRateModel instead of AffineModel

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Exposing CallableFixedRateBond to QuantLibXL: how to use ShortRateModel instead of AffineModel

Lisa Ann
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?
Reply | Threaded
Open this post in threaded view
|

Re: Exposing CallableFixedRateBond to QuantLibXL: how to use ShortRateModel instead of AffineModel

Eric Ehlers-3
Hello,

Here is a link to a message that I sent to quantlib-dev:

http://sourceforge.net/p/quantlib/mailman/quantlib-dev/thread/20150905020101.21863ea9%40laptop/#msg34433578

QuantLibXL 1.7 will be built using the reposit platform, which
supersedes gensrc.  An update to the above message, I talked about some
changes that would break backward compatibility but now I am hoping to
provide a switch which would preserve backward compatibility and which
would be the default.

If you are feeling brave you might want to try exporting your functions
using a pre-release snapshot of the reposit 1.7 build, the
documentation for that is here:

http://quantlib.org/reposit/docs/latest/build_git_swig_windows.html

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

Off the top of my head I would think that if you encounter this
problem in the new build then it could be resolved using some
handwritten code in the QuantLibAddin layer.

Kind Regards,
Eric

On Thu, 24 Sep 2015 03:04:34 -0700 (MST)
Lisa Ann <[hidden email]> wrote:

> I've followed  this
> <http://quantlib.org/quantlibaddin//extend_tutorial.html#extend_wrap>  
> 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?
>
>
>
> --
> View this message in context:
> http://quantlib.10058.n7.nabble.com/Exposing-CallableFixedRateBond-to-QuantLibXL-how-to-use-ShortRateModel-instead-of-AffineModel-tp16923.html
> Sent from the quantlib-users mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> _______________________________________________
> QuantLib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/quantlib-users


------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users