/src/quantlib/ql/methods/finitedifferences/utilities/fdmescrowedloginnervaluecalculator.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2021 Klaus Spanderen |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <https://www.quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | /*! \file fdmescrowedloginnervaluecalculator.cpp |
21 | | */ |
22 | | |
23 | | #include <ql/instruments/payoffs.hpp> |
24 | | #include <ql/methods/finitedifferences/meshers/fdmmesher.hpp> |
25 | | #include <ql/methods/finitedifferences/utilities/fdmescrowedloginnervaluecalculator.hpp> |
26 | | |
27 | | namespace QuantLib { |
28 | | |
29 | | FdmEscrowedLogInnerValueCalculator::FdmEscrowedLogInnerValueCalculator( |
30 | | ext::shared_ptr<EscrowedDividendAdjustment> escrowedDividendAdj, |
31 | | ext::shared_ptr<Payoff> payoff, |
32 | | ext::shared_ptr<FdmMesher> mesher, |
33 | | Size direction) |
34 | 0 | : escrowedDividendAdj_(std::move(escrowedDividendAdj)), |
35 | 0 | payoff_(std::move(payoff)), mesher_(std::move(mesher)), |
36 | 0 | direction_(direction) {} |
37 | | |
38 | | Real FdmEscrowedLogInnerValueCalculator::innerValue( |
39 | 0 | const FdmLinearOpIterator& iter, Time t) { |
40 | |
|
41 | 0 | const Real s_t = std::exp(mesher_->location(iter, direction_)); |
42 | 0 | const Real spot = s_t - escrowedDividendAdj_->dividendAdjustment(t); |
43 | |
|
44 | 0 | return (*payoff_)(spot); |
45 | 0 | } |
46 | | |
47 | | Real FdmEscrowedLogInnerValueCalculator::avgInnerValue( |
48 | 0 | const FdmLinearOpIterator& iter, Time t) { |
49 | 0 | return innerValue(iter, t); |
50 | 0 | } |
51 | | } |