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

#include <qle/models/defaultableequityjumpdiffusionmodel.hpp>

+ Inheritance diagram for DefaultableEquityJumpDiffusionModelBuilder:
+ Collaboration diagram for DefaultableEquityJumpDiffusionModelBuilder:

Public Types

enum class  BootstrapMode { Alternating , Simultaneously }
 

Public Member Functions

 DefaultableEquityJumpDiffusionModelBuilder (const std::vector< Real > &stepTimes, const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &equity, const Handle< QuantLib::BlackVolTermStructure > &volatility, const Handle< QuantLib::DefaultProbabilityTermStructure > &creditCurve, const Real p=0.0, const Real eta=1.0, const bool staticMesher=false, const Size timeStepsPerYear=24, const Size stateGridPoints=100, const Real mesherEpsilon=1E-4, const Real mesherScaling=1.5, const Real mesherConcentration=Null< Real >(), const BootstrapMode mode=BootstrapMode::Alternating, const bool enforceFokkerPlanckBootstrap=false, const bool calibrate=true, const bool adjustEquityVolatility=true, const bool adjustEquityForward=true)
 
Handle< DefaultableEquityJumpDiffusionModelmodel () const
 
- Public Member Functions inherited from ModelBuilder
void recalibrate () const
 recalibrate model, if necessary More...
 
virtual void forceRecalculate ()
 force recalibration of model More...
 
virtual bool requiresRecalibration () const =0
 if false is returned, the model does not require a recalibration More...
 

ModelBuilder interface

std::vector< Real > stepTimes_
 
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2equity_
 
Handle< BlackVolTermStructurevolatility_
 
Handle< DefaultProbabilityTermStructure > creditCurve_
 
Real p_
 
Real eta_
 
bool staticMesher_
 
Size timeStepsPerYear_
 
Size stateGridPoints_
 
Real mesherEpsilon_
 
Real mesherScaling_
 
Real mesherConcentration_
 
BootstrapMode bootstrapMode_
 
bool enforceFokkerPlanckBootstrap_
 
bool calibrate_
 
bool adjustEquityVolatility_
 
bool adjustEquityForward_
 
bool forceCalibration_ = false
 
QuantLib::ext::shared_ptr< MarketObservermarketObserver_
 
std::vector< Real > cachedForwards_
 
std::vector< Real > cachedVariances_
 
RelinkableHandle< DefaultableEquityJumpDiffusionModelmodel_
 
void forceRecalculate () override
 force recalibration of model More...
 
bool requiresRecalibration () const override
 if false is returned, the model does not require a recalibration More...
 
void performCalculations () const override
 
bool calibrationPointsChanged (const bool updateCache) const
 

Detailed Description

Definition at line 43 of file defaultableequityjumpdiffusionmodel.hpp.

Member Enumeration Documentation

◆ BootstrapMode

enum class BootstrapMode
strong

Constructor & Destructor Documentation

◆ DefaultableEquityJumpDiffusionModelBuilder()

DefaultableEquityJumpDiffusionModelBuilder ( const std::vector< Real > &  stepTimes,
const QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > &  equity,
const Handle< QuantLib::BlackVolTermStructure > &  volatility,
const Handle< QuantLib::DefaultProbabilityTermStructure > &  creditCurve,
const Real  p = 0.0,
const Real  eta = 1.0,
const bool  staticMesher = false,
const Size  timeStepsPerYear = 24,
const Size  stateGridPoints = 100,
const Real  mesherEpsilon = 1E-4,
const Real  mesherScaling = 1.5,
const Real  mesherConcentration = Null<Real>(),
const BootstrapMode  mode = BootstrapMode::Alternating,
const bool  enforceFokkerPlanckBootstrap = false,
const bool  calibrate = true,
const bool  adjustEquityVolatility = true,
const bool  adjustEquityForward = true 
)

Definition at line 37 of file defaultableequityjumpdiffusionmodel.cpp.

44 : stepTimes_(stepTimes), equity_(equity), volatility_(volatility), creditCurve_(creditCurve), p_(p), eta_(eta),
45 staticMesher_(staticMesher), timeStepsPerYear_(timeStepsPerYear), stateGridPoints_(stateGridPoints),
46 mesherEpsilon_(mesherEpsilon), mesherScaling_(mesherScaling), mesherConcentration_(mesherConcentration),
47 bootstrapMode_(bootstrapMode), enforceFokkerPlanckBootstrap_(enforceFokkerPlanckBootstrap), calibrate_(calibrate),
48 adjustEquityVolatility_(adjustEquityVolatility), adjustEquityForward_(adjustEquityForward) {
49
50 // checks
51
52 QL_REQUIRE(!stepTimes.empty(), "DefaultableEquityJumpDiffusionModel: at least one step time required");
53 QL_REQUIRE(close_enough(p_, 0.0) || adjustEquityVolatility_,
54 "DefaultableEquityJumpDiffusionModel: for p != 0 (" << p_ << ") adjustEquityVolatility must be true");
55
56 // register with observables
57
58 marketObserver_ = QuantLib::ext::make_shared<MarketObserver>();
59 marketObserver_->registerWith(equity_);
60 marketObserver_->registerWith(creditCurve_);
61
62 registerWith(volatility_);
63 registerWith(marketObserver_);
64
65 // notify observers of all market data changes, not only when not calculated
66 alwaysForwardNotifications();
67}
QuantLib::ext::shared_ptr< QuantExt::EquityIndex2 > equity_
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ model()

Handle< DefaultableEquityJumpDiffusionModel > model ( ) const

Definition at line 69 of file defaultableequityjumpdiffusionmodel.cpp.

69 {
70 calculate();
71 return model_;
72}
RelinkableHandle< DefaultableEquityJumpDiffusionModel > model_

◆ forceRecalculate()

void forceRecalculate ( )
overridevirtual

force recalibration of model

Reimplemented from ModelBuilder.

Definition at line 74 of file defaultableequityjumpdiffusionmodel.cpp.

+ Here is the call graph for this function:

◆ requiresRecalibration()

bool requiresRecalibration ( ) const
overridevirtual

if false is returned, the model does not require a recalibration

Implements ModelBuilder.

Definition at line 80 of file defaultableequityjumpdiffusionmodel.cpp.

80 {
81 return calibrationPointsChanged(false) || marketObserver_->hasUpdated(false) || forceCalibration_;
82}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprivate

Definition at line 123 of file defaultableequityjumpdiffusionmodel.cpp.

123 {
124
125 if (requiresRecalibration()) {
126
128
129 // reset market observer's updated flag
130
131 marketObserver_->hasUpdated(true);
132
133 // setup model and bootstrap the model parameters
134
135 std::vector<Real> h0(stepTimes_.size(), 0.0);
136 std::vector<Real> sigma(stepTimes_.size(), 0.10);
137 model_.linkTo(QuantLib::ext::make_shared<DefaultableEquityJumpDiffusionModel>(
138 stepTimes_, h0, sigma, equity_, creditCurve_, volatility_->dayCounter(), p_, eta_, adjustEquityForward_));
139 if (calibrate_) {
143 }
144
145 // notify model observers
146 model_->notifyObservers();
147 }
148}
bool requiresRecalibration() const override
if false is returned, the model does not require a recalibration
+ Here is the call graph for this function:

◆ calibrationPointsChanged()

bool calibrationPointsChanged ( const bool  updateCache) const
private

Definition at line 84 of file defaultableequityjumpdiffusionmodel.cpp.

84 {
85
86 // get the current foewards and vols
87
88 std::vector<Real> forwards;
89 std::vector<Real> variances;
90 for (auto const t : stepTimes_) {
91 forwards.push_back(equity_->equitySpot()->value() * equity_->equityDividendCurve()->discount(t) /
92 equity_->equityForecastCurve()->discount(t));
93 variances.push_back(volatility_->blackVariance(t, forwards.back()));
94 }
95
96 // check for differences
97
98 bool changed = false;
99 if (stepTimes_.size() != cachedForwards_.size() || stepTimes_.size() != cachedVariances_.size()) {
100 changed = true;
101 } else {
102 for (Size i = 0; i < stepTimes_.size() && !changed; ++i) {
103 // strict comparison is deliberate here!
104 if (cachedForwards_[i] != forwards[i])
105 changed = true;
106 else if (cachedVariances_[i] != variances[i])
107 changed = true;
108 }
109 }
110
111 // update cache if caller desires so
112
113 if (updateCache) {
114 cachedForwards_ = forwards;
115 cachedVariances_ = variances;
116 }
117
118 // return the result
119
120 return changed;
121}
+ Here is the caller graph for this function:

Member Data Documentation

◆ stepTimes_

std::vector<Real> stepTimes_
private

Definition at line 69 of file defaultableequityjumpdiffusionmodel.hpp.

◆ equity_

QuantLib::ext::shared_ptr<QuantExt::EquityIndex2> equity_
private

Definition at line 70 of file defaultableequityjumpdiffusionmodel.hpp.

◆ volatility_

Handle<BlackVolTermStructure> volatility_
private

Definition at line 71 of file defaultableequityjumpdiffusionmodel.hpp.

◆ creditCurve_

Handle<DefaultProbabilityTermStructure> creditCurve_
private

Definition at line 72 of file defaultableequityjumpdiffusionmodel.hpp.

◆ p_

Real p_
private

Definition at line 73 of file defaultableequityjumpdiffusionmodel.hpp.

◆ eta_

Real eta_
private

Definition at line 73 of file defaultableequityjumpdiffusionmodel.hpp.

◆ staticMesher_

bool staticMesher_
private

Definition at line 74 of file defaultableequityjumpdiffusionmodel.hpp.

◆ timeStepsPerYear_

Size timeStepsPerYear_
private

Definition at line 75 of file defaultableequityjumpdiffusionmodel.hpp.

◆ stateGridPoints_

Size stateGridPoints_
private

Definition at line 76 of file defaultableequityjumpdiffusionmodel.hpp.

◆ mesherEpsilon_

Real mesherEpsilon_
private

Definition at line 77 of file defaultableequityjumpdiffusionmodel.hpp.

◆ mesherScaling_

Real mesherScaling_
private

Definition at line 78 of file defaultableequityjumpdiffusionmodel.hpp.

◆ mesherConcentration_

Real mesherConcentration_
private

Definition at line 79 of file defaultableequityjumpdiffusionmodel.hpp.

◆ bootstrapMode_

BootstrapMode bootstrapMode_
private

Definition at line 80 of file defaultableequityjumpdiffusionmodel.hpp.

◆ enforceFokkerPlanckBootstrap_

bool enforceFokkerPlanckBootstrap_
private

Definition at line 81 of file defaultableequityjumpdiffusionmodel.hpp.

◆ calibrate_

bool calibrate_
private

Definition at line 82 of file defaultableequityjumpdiffusionmodel.hpp.

◆ adjustEquityVolatility_

bool adjustEquityVolatility_
private

Definition at line 83 of file defaultableequityjumpdiffusionmodel.hpp.

◆ adjustEquityForward_

bool adjustEquityForward_
private

Definition at line 84 of file defaultableequityjumpdiffusionmodel.hpp.

◆ forceCalibration_

bool forceCalibration_ = false
private

Definition at line 86 of file defaultableequityjumpdiffusionmodel.hpp.

◆ marketObserver_

QuantLib::ext::shared_ptr<MarketObserver> marketObserver_
private

Definition at line 87 of file defaultableequityjumpdiffusionmodel.hpp.

◆ cachedForwards_

std::vector<Real> cachedForwards_
mutableprivate

Definition at line 89 of file defaultableequityjumpdiffusionmodel.hpp.

◆ cachedVariances_

std::vector<Real> cachedVariances_
mutableprivate

Definition at line 90 of file defaultableequityjumpdiffusionmodel.hpp.

◆ model_

RelinkableHandle<DefaultableEquityJumpDiffusionModel> model_
mutableprivate

Definition at line 92 of file defaultableequityjumpdiffusionmodel.hpp.