Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a few missing methods to some short-rate models #691

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 19 additions & 9 deletions SWIG/shortratemodels.i
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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<YieldTermStructure>& 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<YieldTermStructure>& termStructure() const;
};

%shared_ptr(G2)
Expand All @@ -128,6 +136,8 @@ class G2 : public ShortRateModel {

// TermStructureConsistentModel
const Handle<YieldTermStructure>& termStructure() const;

AFFINE_METHODS;
};


Expand Down