Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fdmdefaultableequityjumpdiffusionop.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 Quaternion Risk Management Ltd
3
4 This file is part of ORE, a free-software/open-source library
5 for transparent pricing and risk analysis - http://opensourcerisk.org
6
7 ORE is free software: you can redistribute it and/or modify it
8 under the terms of the Modified BSD License. You should have received a
9 copy of the license along with this program.
10 The license is also available online at <http://opensourcerisk.org>
11
12 This program is distributed on the basis that it will form a useful
13 contribution to risk analytics and model standardisation, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
16*/
17
18/*! \file qle/methods/fdmdefaultableequityjumpdiffusionop.hpp */
19
20#pragma once
21
23#include <ql/methods/finitedifferences/operators/fdmlinearopcomposite.hpp>
24#include <ql/methods/finitedifferences/operators/firstderivativeop.hpp>
25#include <ql/methods/finitedifferences/operators/triplebandlinearop.hpp>
26
27#include <functional>
28
29namespace QuantExt {
30
31using QuantLib::Array;
32using QuantLib::Size;
33
34class FdmDefaultableEquityJumpDiffusionOp : public QuantLib::FdmLinearOpComposite {
35public:
36 /*! - The recovery is given as a function of (t, S, conversionRatio)
37 - The model rate r can be overwritten with a discountingCurve, this is used in the discounting
38 term of the operator then, but not the drift term. This can e.g. be bond discounting curve in
39 convertible bond pricings.
40 - An additional credit curve and associated recovery rate function can be specified, which will constitute
41 an additional discounting term and recovery term. This can e.g. be the bond credit curve for exchangeable
42 convertible bonds (in this context, the model credit curve will be the equity credit curve then).
43 */
45 const QuantLib::ext::shared_ptr<QuantLib::FdmMesher>& mesher,
46 const QuantLib::ext::shared_ptr<DefaultableEquityJumpDiffusionModel>& model, const Size direction = 0,
47 const std::function<Real(Real, Real, Real)>& recovery = {},
48 const Handle<QuantLib::YieldTermStructure>& discountingCurve = Handle<QuantLib::YieldTermStructure>(),
49 const Handle<QuantLib::Quote>& discountingSpread = Handle<QuantLib::Quote>(),
50 const Handle<QuantLib::DefaultProbabilityTermStructure>& addCreditCurve =
51 Handle<QuantLib::DefaultProbabilityTermStructure>(),
52 const std::function<Real(Real, Real, Real)>& addRecovery = {});
53
54 Size size() const override;
55 void setTime(Time t1, Time t2) override;
56
57 Array apply(const Array& r) const override;
58 Array apply_mixed(const Array& r) const override;
59 Array apply_direction(Size direction, const Array& r) const override;
60 Array solve_splitting(Size direction, const Array& r, Real s) const override;
61 Array preconditioner(const Array& r, Real s) const override;
62
63#if !defined(QL_NO_UBLAS_SUPPORT)
64 std::vector<QuantLib::SparseMatrix> toMatrixDecomp() const override;
65#endif
66
67 // conversion ratio as a function of S, used to evaluate the recovery term
68 void setConversionRatio(const std::function<Real(Real)>& conversionRatio);
69
70private:
71 QuantLib::ext::shared_ptr<QuantLib::FdmMesher> mesher_;
72 QuantLib::ext::shared_ptr<DefaultableEquityJumpDiffusionModel> model_;
74 std::function<Real(Real, Real, Real)> recovery_;
75 Handle<QuantLib::YieldTermStructure> discountingCurve_;
76 Handle<QuantLib::DefaultProbabilityTermStructure> addCreditCurve_;
77 std::function<Real(Real, Real, Real)> addRecovery_;
78 Handle<QuantLib::Quote> discountingSpread_;
79
80 QuantLib::FirstDerivativeOp dxMap_;
81 QuantLib::TripleBandLinearOp dxxMap_;
82 QuantLib::TripleBandLinearOp mapT_;
84
85 std::function<Real(Real)> conversionRatio_;
86};
87
88} // namespace QuantExt
Handle< QuantLib::DefaultProbabilityTermStructure > addCreditCurve_
Array apply_direction(Size direction, const Array &r) const override
Array preconditioner(const Array &r, Real s) const override
QuantLib::ext::shared_ptr< QuantLib::FdmMesher > mesher_
std::vector< QuantLib::SparseMatrix > toMatrixDecomp() const override
Array solve_splitting(Size direction, const Array &r, Real s) const override
void setConversionRatio(const std::function< Real(Real)> &conversionRatio)
QuantLib::ext::shared_ptr< DefaultableEquityJumpDiffusionModel > model_