diff --git a/SWIG/shortratemodels.i b/SWIG/shortratemodels.i index 5abddb66b..8a798bec6 100644 --- a/SWIG/shortratemodels.i +++ b/SWIG/shortratemodels.i @@ -55,17 +55,24 @@ using QuantLib::CoxIngersollRoss; using QuantLib::ExtendedCoxIngersollRoss; %} +%define AFFINE_METHODS + DiscountFactor discount(Time t) const; + Real discountBond(Time now, + Time maturity, + Array factors) const; + Real discountBondOption(Option::Type type, + Real strike, + Time maturity, + Time bondMaturity) const; +%enddef + %shared_ptr(OneFactorAffineModel) class OneFactorAffineModel : public ShortRateModel { private: OneFactorAffineModel(); public: - virtual Real discountBond(Time now, - Time maturity, - Array factors) const; - + AFFINE_METHODS; Real discountBond(Time now, Time maturity, Rate rate) const; - DiscountFactor discount(Time t) const; }; %shared_ptr(Vasicek) @@ -103,20 +110,21 @@ class BlackKarasinski : public ShortRateModel { }; %shared_ptr(CoxIngersollRoss) -class CoxIngersollRoss : public ShortRateModel { +class CoxIngersollRoss : public OneFactorAffineModel { public: CoxIngersollRoss(Rate r0= 0.01, Real theta = 0.1, Real k = 0.1, Real sigma = 0.1); - DiscountFactor discount(Time t) const; }; %shared_ptr(ExtendedCoxIngersollRoss) -class ExtendedCoxIngersollRoss : public ShortRateModel { +class ExtendedCoxIngersollRoss : public CoxIngersollRoss { public: ExtendedCoxIngersollRoss(const Handle& termStructure, Real theta = 0.1, Real k = 0.1, Real sigma = 0.1, Real x0 = 0.05); - DiscountFactor discount(Time t) const; + + // TermStructureConsistentModel + const Handle& termStructure() const; }; %shared_ptr(G2) @@ -128,6 +136,8 @@ class G2 : public ShortRateModel { // TermStructureConsistentModel const Handle& termStructure() const; + + AFFINE_METHODS; };