Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
fdmblackscholesop.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file fdmblackscholesop.hpp
20 \brief extended version of the QuantLib class, see the documentation for details
21
22*/
23
24#pragma once
25
27
28#include <ql/methods/finitedifferences/operators/fdmlinearopcomposite.hpp>
29#include <ql/methods/finitedifferences/operators/firstderivativeop.hpp>
30#include <ql/methods/finitedifferences/operators/triplebandlinearop.hpp>
31#include <ql/payoff.hpp>
32#include <ql/processes/blackscholesprocess.hpp>
33
34namespace QuantExt {
35using namespace QuantLib;
36
37/* Black Scholes linear operator as in QuantLib. In addition, if strike = null the volatility
38 at the atmf level is used, more precisely, a forward variance is calculated as
39
40 V(t1, t2, atmf) = V(t2, k2) - V(t1, k1)
41
42 with k1 and k2 the respective atmf levels at t1 and t2.
43
44 The discounting term -r dt can be suppressed setting discounting = false.
45
46 If ensureNonNegativeForwardVariance is true, the forward variances from the input vol ts are floored at zero. */
47class FdmBlackScholesOp : public FdmLinearOpComposite {
48public:
49 FdmBlackScholesOp(const ext::shared_ptr<FdmMesher>& mesher,
50 const ext::shared_ptr<GeneralizedBlackScholesProcess>& process, Real strike = Null<Real>(),
51 bool localVol = false, Real illegalLocalVolOverwrite = -Null<Real>(), Size direction = 0,
52 const ext::shared_ptr<FdmQuantoHelper>& quantoHelper = ext::shared_ptr<FdmQuantoHelper>(),
53 const bool discounting = true, const bool ensureNonNegativeForwardVariance = false);
54
55 Size size() const override;
56 void setTime(Time t1, Time t2) override;
57
58 Array apply(const Array& r) const override;
59 Array apply_mixed(const Array& r) const override;
60 Array apply_direction(Size direction, const Array& r) const override;
61 Array solve_splitting(Size direction, const Array& r, Real s) const override;
62 Array preconditioner(const Array& r, Real s) const override;
63
64#if !defined(QL_NO_UBLAS_SUPPORT)
65 std::vector<QuantLib::SparseMatrix> toMatrixDecomp() const override;
66#endif
67private:
68 const ext::shared_ptr<FdmMesher> mesher_;
69 const ext::shared_ptr<YieldTermStructure> rTS_, qTS_;
70 const ext::shared_ptr<BlackVolTermStructure> volTS_;
71 const ext::shared_ptr<LocalVolTermStructure> localVol_;
72 const Array x_;
73 const FirstDerivativeOp dxMap_;
74 const TripleBandLinearOp dxxMap_;
75 TripleBandLinearOp mapT_;
76 const Real strike_;
78 const Size direction_;
79 const ext::shared_ptr<FdmQuantoHelper> quantoHelper_;
80 const Real initialValue_;
81 const bool discounting_;
83};
84} // namespace QuantExt
Size size() const override
Array apply_direction(Size direction, const Array &r) const override
Array preconditioner(const Array &r, Real s) const override
std::vector< QuantLib::SparseMatrix > toMatrixDecomp() const override
const TripleBandLinearOp dxxMap_
const ext::shared_ptr< FdmQuantoHelper > quantoHelper_
void setTime(Time t1, Time t2) override
Array apply_mixed(const Array &r) const override
const ext::shared_ptr< YieldTermStructure > qTS_
const FirstDerivativeOp dxMap_
const ext::shared_ptr< FdmMesher > mesher_
Array solve_splitting(Size direction, const Array &r, Real s) const override
const ext::shared_ptr< YieldTermStructure > rTS_
const ext::shared_ptr< BlackVolTermStructure > volTS_
Array apply(const Array &r) const override
const ext::shared_ptr< LocalVolTermStructure > localVol_
extended version of the QuantLib class, see the documentation for details