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

#include <qle/methods/fdmdefaultableequityjumpdiffusionop.hpp>

+ Inheritance diagram for FdmDefaultableEquityJumpDiffusionOp:
+ Collaboration diagram for FdmDefaultableEquityJumpDiffusionOp:

Public Member Functions

 FdmDefaultableEquityJumpDiffusionOp (const QuantLib::ext::shared_ptr< QuantLib::FdmMesher > &mesher, const QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > &model, const Size direction=0, const std::function< Real(Real, Real, Real)> &recovery={}, const Handle< QuantLib::YieldTermStructure > &discountingCurve=Handle< QuantLib::YieldTermStructure >(), const Handle< QuantLib::Quote > &discountingSpread=Handle< QuantLib::Quote >(), const Handle< QuantLib::DefaultProbabilityTermStructure > &addCreditCurve=Handle< QuantLib::DefaultProbabilityTermStructure >(), const std::function< Real(Real, Real, Real)> &addRecovery={})
 
Size size () const override
 
void setTime (Time t1, Time t2) override
 
Array apply (const Array &r) const override
 
Array apply_mixed (const Array &r) const override
 
Array apply_direction (Size direction, const Array &r) const override
 
Array solve_splitting (Size direction, const Array &r, Real s) const override
 
Array preconditioner (const Array &r, Real s) const override
 
std::vector< QuantLib::SparseMatrix > toMatrixDecomp () const override
 
void setConversionRatio (const std::function< Real(Real)> &conversionRatio)
 

Private Attributes

QuantLib::ext::shared_ptr< QuantLib::FdmMesher > mesher_
 
QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModelmodel_
 
Size direction_
 
std::function< Real(Real, Real, Real)> recovery_
 
Handle< QuantLib::YieldTermStructure > discountingCurve_
 
Handle< QuantLib::DefaultProbabilityTermStructure > addCreditCurve_
 
std::function< Real(Real, Real, Real)> addRecovery_
 
Handle< QuantLib::Quote > discountingSpread_
 
QuantLib::FirstDerivativeOp dxMap_
 
QuantLib::TripleBandLinearOp dxxMap_
 
QuantLib::TripleBandLinearOp mapT_
 
Array recoveryTerm_
 
std::function< Real(Real)> conversionRatio_
 

Detailed Description

Definition at line 34 of file fdmdefaultableequityjumpdiffusionop.hpp.

Constructor & Destructor Documentation

◆ FdmDefaultableEquityJumpDiffusionOp()

FdmDefaultableEquityJumpDiffusionOp ( const QuantLib::ext::shared_ptr< QuantLib::FdmMesher > &  mesher,
const QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > &  model,
const Size  direction = 0,
const std::function< Real(Real, Real, Real)> &  recovery = {},
const Handle< QuantLib::YieldTermStructure > &  discountingCurve = Handle<QuantLib::YieldTermStructure>(),
const Handle< QuantLib::Quote > &  discountingSpread = Handle<QuantLib::Quote>(),
const Handle< QuantLib::DefaultProbabilityTermStructure > &  addCreditCurve = Handle<QuantLib::DefaultProbabilityTermStructure>(),
const std::function< Real(Real, Real, Real)> &  addRecovery = {} 
)
  • The recovery is given as a function of (t, S, conversionRatio)
  • The model rate r can be overwritten with a discountingCurve, this is used in the discounting term of the operator then, but not the drift term. This can e.g. be bond discounting curve in convertible bond pricings.
  • An additional credit curve and associated recovery rate function can be specified, which will constitute an additional discounting term and recovery term. This can e.g. be the bond credit curve for exchangeable convertible bonds (in this context, the model credit curve will be the equity credit curve then).

Definition at line 27 of file fdmdefaultableequityjumpdiffusionop.cpp.

34 : mesher_(mesher), model_(model), direction_(direction), recovery_(recovery), discountingCurve_(discountingCurve),
35 addCreditCurve_(addCreditCurve), addRecovery_(addRecovery), discountingSpread_(discountingSpread),
36 dxMap_(FirstDerivativeOp(direction, mesher)), dxxMap_(SecondDerivativeOp(direction, mesher)),
37 mapT_(direction, mesher), recoveryTerm_(mesher_->locations(direction).size()) {}
Handle< QuantLib::DefaultProbabilityTermStructure > addCreditCurve_
QuantLib::ext::shared_ptr< QuantLib::FdmMesher > mesher_
QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > model_

Member Function Documentation

◆ size()

Size size ( ) const
override

Definition at line 39 of file fdmdefaultableequityjumpdiffusionop.cpp.

39{ return 1ul; }

◆ setTime()

void setTime ( Time  t1,
Time  t2 
)
override

Definition at line 41 of file fdmdefaultableequityjumpdiffusionop.cpp.

41 {
42
43 Size n = mesher_->locations(direction_).size();
44
45 Real r = model_->r(t1);
46 Real q = model_->q(t1);
47 Real v = model_->sigma(t1) * model_->sigma(t1);
48
49 Array h(n);
50 for (Size i = 0; i < h.size(); ++i) {
51 h[i] = model_->h(t1, std::exp(mesher_->locations(direction_)[i]));
52 }
53
54 // overwrite discounting term with external curve and / or add external spread
55
56 Real r_dis = r;
57 if (!discountingCurve_.empty()) {
58 r_dis = discountingCurve_->forwardRate(t1, t2, Continuous);
59 }
60 if (!discountingSpread_.empty()) {
61 r_dis += discountingSpread_->value();
62 }
63
64 // additional credit discounting term
65
66 Array h2(n, 0.0);
67 if (!addCreditCurve_.empty()) {
68 QL_REQUIRE(!close_enough(addCreditCurve_->survivalProbability(t1), 0.0),
69 "FdmDefaultableEquityJumpDiffusionOp: addCreditCurve implies zero survival probability at t = "
70 << t1
71 << ", this can not be handled. Check the credit curve / security spread provided in the market "
72 "data. If this happens during a spread imply, the target price might not be ataainable even "
73 "for high spreads.");
74 Real tmp =
75 -std::log(addCreditCurve_->survivalProbability(t2) / addCreditCurve_->survivalProbability(t1)) / (t2 - t1);
76 std::fill(h2.begin(), h2.end(), tmp);
77 }
78
79 Array drift(n, r - q - 0.5 * v);
80 if (model_->adjustEquityForward())
81 drift += model_->eta() * h;
82 mapT_.axpyb(drift, dxMap_, dxxMap_.mult(Array(n, 0.5 * v)), -(Array(n, r_dis) + h + h2));
83
84 for (Size i = 0; i < n; ++i) {
85 Real S = std::exp(mesher_->locations(direction_)[i]);
86 Real cr = conversionRatio_ ? conversionRatio_(S) : Null<Real>();
87 recoveryTerm_[i] = 0.0;
88 if (recovery_) {
89 recoveryTerm_[i] += recovery_(t1, S, cr) * h[i];
90 }
91 if (addRecovery_) {
92 recoveryTerm_[i] += addRecovery_(t1, S, cr) * h2[i];
93 }
94 }
95}
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

◆ apply()

Array apply ( const Array &  r) const
override

Definition at line 97 of file fdmdefaultableequityjumpdiffusionop.cpp.

97 {
98 return mapT_.apply(r) + recoveryTerm_;
99}

◆ apply_mixed()

Array apply_mixed ( const Array &  r) const
override

Definition at line 101 of file fdmdefaultableequityjumpdiffusionop.cpp.

101 {
102 Array retVal(r.size(), 0.0);
103 return retVal;
104}

◆ apply_direction()

Array apply_direction ( Size  direction,
const Array &  r 
) const
override

Definition at line 106 of file fdmdefaultableequityjumpdiffusionop.cpp.

106 {
107 if (direction == direction_)
108 return mapT_.apply(r);
109 else {
110 Array retVal(r.size(), 0.0);
111 return retVal;
112 }
113}

◆ solve_splitting()

Array solve_splitting ( Size  direction,
const Array &  r,
Real  s 
) const
override

Definition at line 115 of file fdmdefaultableequityjumpdiffusionop.cpp.

115 {
116 if (direction == direction_) {
117 return mapT_.solve_splitting(r, s, 1.0);
118 } else {
119 Array retVal(r);
120 return retVal;
121 }
122}
+ Here is the caller graph for this function:

◆ preconditioner()

Array preconditioner ( const Array &  r,
Real  s 
) const
override

Definition at line 124 of file fdmdefaultableequityjumpdiffusionop.cpp.

124 {
125 return solve_splitting(direction_, r, s);
126}
Array solve_splitting(Size direction, const Array &r, Real s) const override
+ Here is the call graph for this function:

◆ toMatrixDecomp()

std::vector< QuantLib::SparseMatrix > toMatrixDecomp ( ) const
override

Definition at line 129 of file fdmdefaultableequityjumpdiffusionop.cpp.

129 {
130 std::vector<SparseMatrix> retVal(1, mapT_.toMatrix());
131 return retVal;
132}

◆ setConversionRatio()

void setConversionRatio ( const std::function< Real(Real)> &  conversionRatio)

Definition at line 135 of file fdmdefaultableequityjumpdiffusionop.cpp.

135 {
136 conversionRatio_ = conversionRatio;
137}

Member Data Documentation

◆ mesher_

QuantLib::ext::shared_ptr<QuantLib::FdmMesher> mesher_
private

Definition at line 71 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ model_

QuantLib::ext::shared_ptr<DefaultableEquityJumpDiffusionModel> model_
private

Definition at line 72 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ direction_

Size direction_
private

Definition at line 73 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ recovery_

std::function<Real(Real, Real, Real)> recovery_
private

Definition at line 74 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ discountingCurve_

Handle<QuantLib::YieldTermStructure> discountingCurve_
private

Definition at line 75 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ addCreditCurve_

Handle<QuantLib::DefaultProbabilityTermStructure> addCreditCurve_
private

Definition at line 76 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ addRecovery_

std::function<Real(Real, Real, Real)> addRecovery_
private

Definition at line 77 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ discountingSpread_

Handle<QuantLib::Quote> discountingSpread_
private

Definition at line 78 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ dxMap_

QuantLib::FirstDerivativeOp dxMap_
private

Definition at line 80 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ dxxMap_

QuantLib::TripleBandLinearOp dxxMap_
private

Definition at line 81 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ mapT_

QuantLib::TripleBandLinearOp mapT_
private

Definition at line 82 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ recoveryTerm_

Array recoveryTerm_
private

Definition at line 83 of file fdmdefaultableequityjumpdiffusionop.hpp.

◆ conversionRatio_

std::function<Real(Real)> conversionRatio_
private

Definition at line 85 of file fdmdefaultableequityjumpdiffusionop.hpp.