Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
CirppConstantWithFellerParametrization< TS > Class Template Reference

CIR++ Constant Parametrization. More...

#include <qle/models/cirppconstantfellerparametrization.hpp>

+ Inheritance diagram for CirppConstantWithFellerParametrization< TS >:
+ Collaboration diagram for CirppConstantWithFellerParametrization< TS >:

Public Member Functions

 CirppConstantWithFellerParametrization (const Currency &currency, const Handle< TS > &termStructure, const Real kappa, const Real theta, const Real sigma, const Real y0, const bool shifted, bool relaxed=false, const Real fellerFactor=2.0, const std::string &name=std::string())
 
Real kappa (const Time t) const override
 
Real theta (const Time t) const override
 
Real sigma (const Time t) const override
 
Real y0 (const Time t) const override
 
const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const override
 
const bool relaxed () const
 
- Public Member Functions inherited from CirppParametrization< TS >
 CirppParametrization (const Currency &currency, const Handle< TS > &termStructure, bool shifted, const std::string &name=std::string())
 
virtual Real kappa (const Time t) const =0
 
virtual Real theta (const Time t) const =0
 
virtual Real sigma (const Time t) const =0
 
virtual Real y0 (const Time t) const =0
 
const Handle< TS > termStructure () const
 
const bool shifted () const
 
Size numberOfParameters () const override
 
- Public Member Functions inherited from Parametrization
 Parametrization (const Currency &currency, const std::string &name="")
 
virtual ~Parametrization ()
 
virtual const Currency & currency () const
 
virtual const Array & parameterTimes (const Size) const
 
virtual Size numberOfParameters () const
 
virtual Array parameterValues (const Size) const
 
virtual const QuantLib::ext::shared_ptr< Parameter > parameter (const Size) const
 
virtual void update () const
 
const std::string & name () const
 
virtual Real direct (const Size, const Real x) const
 
virtual Real inverse (const Size, const Real y) const
 

Protected Member Functions

Real direct (const Size i, const Real x) const override
 
Real inverse (const Size j, const Real y) const override
 
- Protected Member Functions inherited from Parametrization
Time tr (const Time t) const
 
Time tl (const Time t) const
 
Time tr2 (const Time t) const
 
Time tm2 (const Time t) const
 
Time tl2 (const Time t) const
 

Private Attributes

const QuantLib::ext::shared_ptr< PseudoParameterkappa_
 
const QuantLib::ext::shared_ptr< PseudoParametertheta_
 
const QuantLib::ext::shared_ptr< PseudoParametersigma_
 
const QuantLib::ext::shared_ptr< PseudoParametery0_
 
bool relaxed_
 
const Real fellerFactor_
 

Additional Inherited Members

- Protected Attributes inherited from Parametrization
const Real h_
 
const Real h2_
 

Detailed Description

template<class TS>
class QuantExt::CirppConstantWithFellerParametrization< TS >

CIR++ Constant Parametrization.

Definition at line 36 of file cirppconstantfellerparametrization.hpp.

Constructor & Destructor Documentation

◆ CirppConstantWithFellerParametrization()

CirppConstantWithFellerParametrization ( const Currency &  currency,
const Handle< TS > &  termStructure,
const Real  kappa,
const Real  theta,
const Real  sigma,
const Real  y0,
const bool  shifted,
bool  relaxed = false,
const Real  fellerFactor = 2.0,
const std::string &  name = std::string() 
)

Definition at line 67 of file cirppconstantfellerparametrization.hpp.

70 : CirppParametrization<TS>(currency, termStructure, shifted, name),
71 kappa_(QuantLib::ext::make_shared<PseudoParameter>(1)),
72 theta_(QuantLib::ext::make_shared<PseudoParameter>(1)), sigma_(QuantLib::ext::make_shared<PseudoParameter>(1)),
73 y0_(QuantLib::ext::make_shared<PseudoParameter>(1)), relaxed_(relaxed), fellerFactor_(fellerFactor) {
74 QL_REQUIRE((relaxed_ ? 4.0 : 2.0) * kappa * theta > sigma * sigma,
75 "CirppConstantWithFellerParametrization: Feller constraint violated (kappa="
76 << kappa << ", theta=" << theta << ", sigma=" << sigma << " (relaxed=" << std::boolalpha << relaxed_
77 << ")");
78 QL_REQUIRE(fellerFactor_ > 1.0, "CirppConstantWithFellerParametrization: Feller factor ("
79 << fellerFactor_ << ") should be greater than 1.0");
80 kappa_->setParam(0, inverse(0, kappa));
81 theta_->setParam(0, inverse(1, theta));
82 sigma_->setParam(0, inverse(2, sigma));
83 y0_->setParam(0, inverse(3, y0));
84}
const QuantLib::ext::shared_ptr< PseudoParameter > theta_
const QuantLib::ext::shared_ptr< PseudoParameter > sigma_
const QuantLib::ext::shared_ptr< PseudoParameter > y0_
Real inverse(const Size j, const Real y) const override
const QuantLib::ext::shared_ptr< PseudoParameter > kappa_
const Handle< TS > termStructure() const
const std::string & name() const
virtual const Currency & currency() const
+ Here is the call graph for this function:

Member Function Documentation

◆ kappa()

Real kappa ( const Time  t) const
overridevirtual

Implements CirppParametrization< TS >.

Definition at line 124 of file cirppconstantfellerparametrization.hpp.

124 {
125 return direct(0, kappa_->params()[0]);
126}
Real direct(const Size i, const Real x) const override
+ Here is the caller graph for this function:

◆ theta()

Real theta ( const Time  t) const
overridevirtual

Implements CirppParametrization< TS >.

Definition at line 128 of file cirppconstantfellerparametrization.hpp.

128 {
129 return direct(1, theta_->params()[0]);
130}
+ Here is the caller graph for this function:

◆ sigma()

Real sigma ( const Time  t) const
overridevirtual

Implements CirppParametrization< TS >.

Definition at line 132 of file cirppconstantfellerparametrization.hpp.

132 {
133 return direct(2, sigma_->params()[0]);
134}
+ Here is the caller graph for this function:

◆ y0()

Real y0 ( const Time  t) const
overridevirtual

Implements CirppParametrization< TS >.

Definition at line 136 of file cirppconstantfellerparametrization.hpp.

136 {
137 return direct(3, y0_->params()[0]);
138}
+ Here is the caller graph for this function:

◆ parameter()

const QuantLib::ext::shared_ptr< Parameter > parameter ( const Size  Size) const
overridevirtual

the parameter storing the raw parameter values

Reimplemented from Parametrization.

Definition at line 146 of file cirppconstantfellerparametrization.hpp.

146 {
147 QL_REQUIRE(i < 4, "parameter " << i << " does not exist, only have 0..3");
148 if (i == 0)
149 return kappa_;
150 else if (i == 1)
151 return theta_;
152 else if (i == 2)
153 return sigma_;
154 else
155 return y0_;
156}

◆ relaxed()

const bool relaxed

Definition at line 140 of file cirppconstantfellerparametrization.hpp.

140 {
141 return relaxed_;
142}

◆ direct()

Real direct ( const Size  Size,
const Real  x 
) const
overrideprotectedvirtual

transformations between raw and actual parameters

Reimplemented from Parametrization.

Definition at line 87 of file cirppconstantfellerparametrization.hpp.

87 {
88 constexpr Real eps = 1E-10;
89 switch (i) {
90 case 0:
91 case 1:
92 case 3:
93 return x * x + eps;
94 case 2: {
95 const Real fellerBound =
96 std::sqrt((relaxed_ ? 4.0 : 2.0) * direct(0, kappa_->params()[0]) * direct(1, theta_->params()[0]));
97 // return fellerBound * (std::atan(x) + M_PI_2 + eps) / (M_PI - 2.0 * eps); // "free sigma"
98 return fellerBound / std::sqrt(fellerFactor_); // tie sigma to kappa/theta on feller boundary
99 }
100 default:
101 QL_FAIL("Index is not defined!");
102 }
103}

◆ inverse()

Real inverse ( const Size  j,
const Real  y 
) const
overrideprotectedvirtual

Reimplemented from Parametrization.

Definition at line 106 of file cirppconstantfellerparametrization.hpp.

106 {
107 constexpr Real eps = 1E-10;
108 switch (i) {
109 case 0:
110 case 1:
111 case 3:
112 return std::sqrt(y - eps);
113 case 2: {
114 const Real fellerBound =
115 std::sqrt((relaxed_ ? 4.0 : 2.0) * direct(0, kappa_->params()[0]) * direct(1, theta_->params()[0]));
116 // return std::tan(y / fellerBound * (M_PI - 2.0 * eps) - M_PI_2 - eps); // see above
117 return fellerBound / std::sqrt(fellerFactor_); // see above
118 }
119 default:
120 QL_FAIL("Index is not defined!");
121 }
122}
+ Here is the caller graph for this function:

Member Data Documentation

◆ kappa_

const QuantLib::ext::shared_ptr<PseudoParameter> kappa_
private

Definition at line 59 of file cirppconstantfellerparametrization.hpp.

◆ theta_

const QuantLib::ext::shared_ptr<PseudoParameter> theta_
private

Definition at line 59 of file cirppconstantfellerparametrization.hpp.

◆ sigma_

const QuantLib::ext::shared_ptr<PseudoParameter> sigma_
private

Definition at line 59 of file cirppconstantfellerparametrization.hpp.

◆ y0_

const QuantLib::ext::shared_ptr<PseudoParameter> y0_
private

Definition at line 59 of file cirppconstantfellerparametrization.hpp.

◆ relaxed_

bool relaxed_
private

Definition at line 60 of file cirppconstantfellerparametrization.hpp.

◆ fellerFactor_

const Real fellerFactor_
private

Definition at line 61 of file cirppconstantfellerparametrization.hpp.