Vasicek 1Factor Model

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

Vasicek 1Factor Model

newbie73
I am using QuantLib .8.0 on OSX 10.3 through the Python SWIG interface.  The Bermudan Swaption example shows the creation of a HullWhite 1 Factor model.  The Vasicek.hpp file suggests that, like the HullWhite model, I should be able to construct a Vasicek 1Factor instance with:

vas = Vasicek(...)

Yet this function cannot be found.  Inspecting the QuantLib namespace with dir(QuantLib) did not reveal a Vasicek(...) function either.  Does anyone know how to create an instance of this model and/or whether there is a problem with the SWIG interface that is preventing it from being visible?

Thanks,

- Luis
Reply | Threaded
Open this post in threaded view
|

Re: Vasicek 1Factor Model

Luigi Ballabio
On Fri, 2007-09-14 at 03:45 -0700, newbie73 wrote:

> I am using QuantLib .8.0 on OSX 10.3 through the Python SWIG interface.  The
> Bermudan Swaption example shows the creation of a HullWhite 1 Factor model.
> The Vasicek.hpp file suggests that, like the HullWhite model, I should be
> able to construct a Vasicek 1Factor instance with:
>
> vas = Vasicek(...)
>
> Yet this function cannot be found.  Inspecting the QuantLib namespace with
> dir(QuantLib) did not reveal a Vasicek(...) function either.  Does anyone
> know how to create an instance of this model and/or whether there is a
> problem with the SWIG interface that is preventing it from being visible?

No, I think it's just not exported. You can modify the relevant SWIG
interface file (shortratemodels.i) and add it---just clone what is done
for the other models.

Later,
        Luigi


--

This gubblick contains many nonsklarkish English flutzpahs, but the
overall pluggandisp can be glorked from context.
-- David Moser



-------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Vasicek 1Factor Model

newbie73

I have added a definition similar to the HullWhite definition, but Vasicek(...) cannot be found in the QuantLib namespace.  The code I added to shortratemodels.i is below:

%{
        using QuantLib::Vasicek;
        typedef boost::shared_ptr<ShortRateModel> VasicekPtr;
%}


%rename(Vasicek) VasicekPtr;
class VasicekPtr : public boost::shared_ptr<ShortRateModel> {
  public:
    %extend
    {
        VasicekPtr( Rate r0 = 0.05,
                                        Real a = 0.1,
                                        Real b = 0.05,
                                        Real sigma = 0.01,
                                        Real lambda = 0.0);
        {
                        return new VasicekPtr(new HullWhite(r0, a, b, sigma, lambda));
                }
                DiscountFactor discount(Time t) const
                {
                        return boost::dynamic_pointer_cast<Vasicek>(*self)->discount(t);
                }
    }
};

---------------------------------------------------
No, I think it's just not exported. You can modify the relevant SWIG
interface file (shortratemodels.i) and add it---just clone what is done
for the other models.

Later,
        Luigi


--

This gubblick contains many nonsklarkish English flutzpahs, but the
overall pluggandisp can be glorked from context.
-- David Moser



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