Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
CrCirppStateProcess Class Reference

CIR++ Model State Process. More...

#include <qle/processes/crcirppstateprocess.hpp>

+ Inheritance diagram for CrCirppStateProcess:
+ Collaboration diagram for CrCirppStateProcess:

Public Types

enum  Discretization { BrigoAlfonsi }
 

Public Member Functions

 CrCirppStateProcess (CrCirpp *const model, CrCirppStateProcess::Discretization disc=CrCirppStateProcess::Discretization::BrigoAlfonsi)
 
Size size () const override
 
Array initialValues () const override
 
Array drift (Time t, const Array &x) const override
 
Matrix diffusion (Time t, const Array &x) const override
 
Array evolve (Time t0, const Array &x0, Time dt, const Array &dw) const override
 
const CrCirppmodel () const
 
const CrCirppStateProcess::Discretization discretization ()
 

Protected Attributes

const CrCirppmodel_
 
const CrCirppStateProcess::Discretization discretization_
 

Detailed Description

CIR++ Model State Process.

Definition at line 37 of file crcirppstateprocess.hpp.

Member Enumeration Documentation

◆ Discretization

Enumerator
BrigoAlfonsi 

Definition at line 39 of file crcirppstateprocess.hpp.

Constructor & Destructor Documentation

◆ CrCirppStateProcess()

Definition at line 28 of file crcirppstateprocess.cpp.

30 : StochasticProcess(QuantLib::ext::shared_ptr<StochasticProcess::discretization>(new EulerDiscretization)), model_(model),
31 discretization_(disc) {}
const CrCirppStateProcess::Discretization discretization_

Member Function Documentation

◆ size()

Size size ( ) const
override

StochasticProcess interface

Definition at line 33 of file crcirppstateprocess.cpp.

33{ return 2; }
+ Here is the caller graph for this function:

◆ initialValues()

Array initialValues ( ) const
override

Definition at line 35 of file crcirppstateprocess.cpp.

35 {
36 Array res(size(), 0.0);
37 res[0] = model_->parametrization()->y0(0); // y0
38 res[1] = 1.0; // S(0,0) = 1
39 return res;
40}
const QuantLib::ext::shared_ptr< CrCirppParametrization > parametrization() const
Definition: crcirpp.hpp:88
+ Here is the call graph for this function:

◆ drift()

Array drift ( Time  t,
const Array &  x 
) const
override

Definition at line 42 of file crcirppstateprocess.cpp.

42 {
43 QL_FAIL("not implemented");
44}

◆ diffusion()

Matrix diffusion ( Time  t,
const Array &  x 
) const
override

Definition at line 46 of file crcirppstateprocess.cpp.

46 {
47 QL_FAIL("not implemented");
48}

◆ evolve()

Array evolve ( Time  t0,
const Array &  x0,
Time  dt,
const Array &  dw 
) const
override

Definition at line 50 of file crcirppstateprocess.cpp.

50 {
51 Array retVal(size());
52 Real kappa, theta, sigma, y0;
53 kappa = model_->parametrization()->kappa(t0);
54 theta = model_->parametrization()->theta(t0);
55 sigma = model_->parametrization()->sigma(t0);
56 y0 = model_->parametrization()->y0(t0);
57
58 const Real sdt = std::sqrt(dt);
59 switch (discretization_) {
60
61 case BrigoAlfonsi: {
62 // see D. Brigo and F. Mercurio. Interest Rate Models: Theory and Practice, 2nd
63 // Edition. Springer, 2006.
64 // Ensures non-negative values for \sigma^2 \leq 2*\kappa*\theta
65 Real temp = (1 - kappa / 2.0 * dt);
66 Real temp2 = temp * std::sqrt(x0[0]) + sigma * sdt * dw[0] / (2.0 * temp);
67 retVal[0] = temp2 * temp2 + (kappa * theta - sigma * sigma / 4) * dt;
68 break;
69 }
70 default:
71 QL_FAIL("unknown discretization schema");
72 }
73
74 // second element is S(0,i)
75 Real SM_ti = model_->defaultCurve()->survivalProbability(t0 + dt);
76 Real SM_ti_pre = model_->defaultCurve()->survivalProbability(t0);
77 Real Pcir_ti = model_->zeroBond(0, t0 + dt, y0);
78 Real Pcir_ti_pre = model_->zeroBond(0, t0, y0);
79 retVal[1] = x0[1] * SM_ti / SM_ti_pre * Pcir_ti_pre / Pcir_ti * exp(-x0[0] * dt);
80
81 return retVal;
82}
Real zeroBond(Real t, Real T, Real y) const
Definition: crcirpp.cpp:124
Handle< DefaultProbabilityTermStructure > defaultCurve(std::vector< Date > dateGrid=std::vector< Date >()) const
Definition: crcirpp.cpp:59
CompiledFormula exp(CompiledFormula x)
+ Here is the call graph for this function:

◆ model()

const CrCirpp * model ( ) const

Definition at line 53 of file crcirppstateprocess.hpp.

53{ return model_; }

◆ discretization()

const CrCirppStateProcess::Discretization discretization ( )

Definition at line 54 of file crcirppstateprocess.hpp.

54{ return discretization_; }

Member Data Documentation

◆ model_

const CrCirpp* model_
protected

Definition at line 57 of file crcirppstateprocess.hpp.

◆ discretization_

const CrCirppStateProcess::Discretization discretization_
protected

Definition at line 58 of file crcirppstateprocess.hpp.