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

#include <qle/models/hwmodel.hpp>

+ Inheritance diagram for HwModel:
+ Collaboration diagram for HwModel:

Public Types

enum class  Discretization { Euler , Exact }
 
- Public Types inherited from IrModel
enum class  Measure { LGM , BA }
 

Public Member Functions

 HwModel (const QuantLib::ext::shared_ptr< IrHwParametrization > &parametrization, const Measure measure=Measure::BA, const Discretization discretization=Discretization::Euler, const bool evaluateBankAccount=true)
 
Measure measure () const override
 
const QuantLib::ext::shared_ptr< ParametrizationparametrizationBase () const override
 
Handle< YieldTermStructure > termStructure () const override
 
Size n () const override
 
Size m () const override
 
Size n_aux () const override
 
Size m_aux () const override
 
QuantLib::ext::shared_ptr< StochasticProcessstateProcess () const override
 
QuantLib::Real discountBond (const QuantLib::Time t, const QuantLib::Time T, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >()) const override
 
QuantLib::Real numeraire (const QuantLib::Time t, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const QuantLib::Array &aux=Array()) const override
 
QuantLib::Real shortRate (const QuantLib::Time t, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >()) const override
 
const QuantLib::ext::shared_ptr< IrHwParametrizationparametrization () const
 
void update () override
 
void generateArguments () override
 
virtual Measure measure () const =0
 
virtual const QuantLib::ext::shared_ptr< ParametrizationparametrizationBase () const =0
 
virtual Handle< YieldTermStructure > termStructure () const =0
 
virtual Size n () const =0
 
virtual Size m () const =0
 
virtual Size n_aux () const =0
 
virtual Size m_aux () const =0
 
virtual QuantLib::ext::shared_ptr< StochasticProcessstateProcess () const =0
 
virtual QuantLib::Real discountBond (const QuantLib::Time t, const QuantLib::Time T, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >()) const =0
 
virtual QuantLib::Real numeraire (const QuantLib::Time t, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), const QuantLib::Array &aux=Array()) const =0
 
virtual QuantLib::Real shortRate (const QuantLib::Time t, const QuantLib::Array &x, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >()) const =0
 
- Public Member Functions inherited from LinkableCalibratedModel
 LinkableCalibratedModel ()
 
void update () override
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 Calibrate to a set of market instruments (usually caps/swaptions) More...
 
virtual void calibrate (const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &, OptimizationMethod &method, const EndCriteria &endCriteria, const Constraint &constraint=Constraint(), const std::vector< Real > &weights=std::vector< Real >(), const std::vector< bool > &fixParameters=std::vector< bool >())
 for backward compatibility More...
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< CalibrationHelper > > &)
 
Real value (const Array &params, const std::vector< QuantLib::ext::shared_ptr< BlackCalibrationHelper > > &)
 for backward compatibility More...
 
const QuantLib::ext::shared_ptr< Constraint > & constraint () const
 
EndCriteria::Type endCriteria () const
 Returns end criteria result. More...
 
const Array & problemValues () const
 Returns the problem values. More...
 
Array params () const
 Returns array of arguments on which calibration is done. More...
 
virtual void setParams (const Array &params)
 
virtual void setParam (Size idx, const Real value)
 

Private Attributes

QuantLib::ext::shared_ptr< IrHwParametrizationparametrization_
 
Measure measure_
 
Discretization discretization_
 
QuantLib::ext::shared_ptr< StochasticProcessstateProcess_
 
bool evaluateBankAccount_
 

Additional Inherited Members

virtual void generateArguments ()
 
- Protected Attributes inherited from LinkableCalibratedModel
std::vector< QuantLib::ext::shared_ptr< Parameter > > arguments_
 
QuantLib::ext::shared_ptr< Constraintconstraint_
 
EndCriteria::Type endCriteria_
 
Array problemValues_
 

Detailed Description

Definition at line 33 of file hwmodel.hpp.

Member Enumeration Documentation

◆ Discretization

enum class Discretization
strong
Enumerator
Euler 
Exact 

Definition at line 35 of file hwmodel.hpp.

Constructor & Destructor Documentation

◆ HwModel()

HwModel ( const QuantLib::ext::shared_ptr< IrHwParametrization > &  parametrization,
const Measure  measure = Measure::BA,
const Discretization  discretization = Discretization::Euler,
const bool  evaluateBankAccount = true 
)

Definition at line 24 of file hwmodel.cpp.

27 evaluateBankAccount_(evaluateBankAccount) {
28 QL_REQUIRE(parametrization_ != nullptr, "HwModel: parametrization is null");
30 QuantLib::ext::make_shared<IrHwStateProcess>(parametrization_, measure_, discretization_, evaluateBankAccount_);
31}
Measure measure_
Definition: hwmodel.hpp:78
const QuantLib::ext::shared_ptr< IrHwParametrization > parametrization() const
Definition: hwmodel.hpp:70
bool evaluateBankAccount_
Definition: hwmodel.hpp:81
QuantLib::ext::shared_ptr< StochasticProcess > stateProcess_
Definition: hwmodel.hpp:80
Measure measure() const override
Definition: hwmodel.hpp:42
Discretization discretization_
Definition: hwmodel.hpp:79
QuantLib::ext::shared_ptr< IrHwParametrization > parametrization_
Definition: hwmodel.hpp:77

Member Function Documentation

◆ measure()

Measure measure ( ) const
overridevirtual

measure under which the model is operated

Implements IrModel.

Definition at line 42 of file hwmodel.hpp.

42{ return measure_; }

◆ parametrizationBase()

const QuantLib::ext::shared_ptr< Parametrization > parametrizationBase ( ) const
overridevirtual

parametrization (as base class)

Implements IrModel.

Definition at line 44 of file hwmodel.hpp.

44{ return parametrization_; }

◆ termStructure()

Handle< YieldTermStructure > termStructure ( ) const
overridevirtual

yield term structure to which the IrModel is (initially) calibrated

Implements IrModel.

Definition at line 46 of file hwmodel.hpp.

46{ return parametrization_->termStructure(); }

◆ n()

Size n ( ) const
overridevirtual

dimension of model state, excluding auxilliary states

Implements IrModel.

Definition at line 69 of file hwmodel.cpp.

69{ return parametrization_->n(); }
+ Here is the caller graph for this function:

◆ m()

Size m ( ) const
overridevirtual

number of Brownians to evolve the state

Implements IrModel.

Definition at line 70 of file hwmodel.cpp.

70{ return parametrization_->m(); }
+ Here is the caller graph for this function:

◆ n_aux()

Size n_aux ( ) const
overridevirtual

(effective) dimension of auxilliary state, typically to evaluate the numeraire in the BA-measure

Implements IrModel.

Definition at line 71 of file hwmodel.cpp.

71{ return evaluateBankAccount_ && measure_ == Measure::BA ? n() : 0; }
Size n() const override
Definition: hwmodel.cpp:69
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ m_aux()

Size m_aux ( ) const
overridevirtual

(effective) number of Brownians required to evolve the auxilliary state, typcially for exact discretization schemes

Implements IrModel.

Definition at line 72 of file hwmodel.cpp.

72 {
74}
Size m() const override
Definition: hwmodel.cpp:70
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stateProcess()

QuantLib::ext::shared_ptr< StochasticProcess > stateProcess ( ) const
overridevirtual

stochastic process, this has dimension n() + n_aux() and m() + m_aux() Brownian drivers

Implements IrModel.

Definition at line 53 of file hwmodel.hpp.

53{ return stateProcess_; }

◆ discountBond()

QuantLib::Real discountBond ( const QuantLib::Time  t,
const QuantLib::Time  T,
const QuantLib::Array &  x,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle< YieldTermStructure >() 
) const
overridevirtual

discount bond depending on state (of dimension n())

Implements IrModel.

Definition at line 33 of file hwmodel.cpp.

34 {
35 if (QuantLib::close_enough(t, T))
36 return 1.0;
37 QL_REQUIRE(T >= t && t >= 0.0, "T(" << T << ") >= t(" << t << ") >= 0 required in HwModel::discountBond");
38 QuantLib::Array gt = parametrization_->g(t, T);
39 QuantLib::Matrix yt = parametrization_->y(t);
40
41 return (discountCurve.empty()
42 ? parametrization_->termStructure()->discount(T) / parametrization_->termStructure()->discount(t)
43 : discountCurve->discount(T) / discountCurve->discount(t)) *
44 std::exp(-QuantLib::DotProduct(gt, x) - 0.5 * QuantLib::DotProduct(gt, yt * gt));
45}

◆ numeraire()

QuantLib::Real numeraire ( const QuantLib::Time  t,
const QuantLib::Array &  x,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle< YieldTermStructure >(),
const QuantLib::Array &  aux = Array() 
) const
overridevirtual

numeraire depending on state and aux state (of dimensions n(), n_aux()

Implements IrModel.

Definition at line 47 of file hwmodel.cpp.

49 {
50 QL_REQUIRE(measure_ == IrModel::Measure::BA, "HwModel::numeraire() supports BA measure only currently.");
51 return std::exp(std::accumulate(aux.begin(), aux.end(), 0.0)) /
52 (discountCurve.empty() ? parametrization_->termStructure()->discount(t) : discountCurve->discount(t));
53}

◆ shortRate()

QuantLib::Real shortRate ( const QuantLib::Time  t,
const QuantLib::Array &  x,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  discountCurve = Handle< YieldTermStructure >() 
) const
overridevirtual

short rate at t

Implements IrModel.

Definition at line 55 of file hwmodel.cpp.

56 {
57 return std::accumulate(x.begin(), x.end(), 0.0) +
58 (discountCurve.empty() ? parametrization_->termStructure()->forwardRate(t, t, Compounding::Continuous)
59 : discountCurve->forwardRate(t, t, Compounding::Continuous));
60}

◆ parametrization()

const QuantLib::ext::shared_ptr< IrHwParametrization > parametrization ( ) const

Definition at line 70 of file hwmodel.hpp.

70{ return parametrization_; }

◆ update()

void update ( )
override

observer and linked calibrated model interface

Definition at line 62 of file hwmodel.cpp.

62 {
63 parametrization_->update();
64 notifyObservers();
65}
+ Here is the caller graph for this function:

◆ generateArguments()

void generateArguments ( )
overridevirtual

Reimplemented from LinkableCalibratedModel.

Definition at line 67 of file hwmodel.cpp.

67{ update(); }
void update() override
Definition: hwmodel.cpp:62
+ Here is the call graph for this function:

Member Data Documentation

◆ parametrization_

QuantLib::ext::shared_ptr<IrHwParametrization> parametrization_
private

Definition at line 77 of file hwmodel.hpp.

◆ measure_

Measure measure_
private

Definition at line 78 of file hwmodel.hpp.

◆ discretization_

Discretization discretization_
private

Definition at line 79 of file hwmodel.hpp.

◆ stateProcess_

QuantLib::ext::shared_ptr<StochasticProcess> stateProcess_
private

Definition at line 80 of file hwmodel.hpp.

◆ evaluateBankAccount_

bool evaluateBankAccount_
private

Definition at line 81 of file hwmodel.hpp.