Login  Register

Re: Which methods to expose to access Discount/FwdRate?

Posted by newbie73 on Sep 17, 2007; 7:36pm
URL: http://quantlib.414.s1.nabble.com/Which-methods-to-expose-to-access-Discount-FwdRate-tp1361p1363.html

I'm using the Python bindings.  I made the changes you suggested, yet after running the setup.py script again with the new version of the .i file, I still cannot view the discount method from an instance of the HullWhite model.

This is what I added to shortratemodels.i:

%rename(HullWhite) HullWhitePtr;
class HullWhitePtr : public boost::shared_ptr<ShortRateModel> {
  public:
    %extend
    {
        HullWhitePtr(const Handle<YieldTermStructure>& termStructure,
                     Real a = 0.1, Real sigma = 0.01)
                     {
                                                return new HullWhitePtr(new HullWhite(termStructure, a, sigma));                        
                                        }
                DiscountFactor discount(Time t) const
                {
                        return boost::dynamic_pointer_cast<HullWhite>(*self)->discount(t);
                }

    }
};



------------------------------------------------------------------------
Hi,
        those methods are not exported in the C# bindings (is that what you're
using, right?) In order to export them, you'll have to add them to the
SWIG interface files and regenerate the wrappers. For instance, you'll
have to go to the definition of the Hull-White model in
shortratemodels.i and add inside the %extend block the following:

DiscountFactor discount(Time t) const {
    return boost::dynamic_pointer_cast<HullWhite>(*self)->discount(t);
}

Luigi


--

The wisdom of the wise and the experience of the ages are perpetuated
by quotations.
-- Benjamin Disraeli



-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
QuantLib-users mailing list
QuantLib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/quantlib-users