QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fdmextoujumpmodelinnervalue.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2011 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 <http://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
25#ifndef quantlib_fdm_ext_ou_jump_model_inner_value_hpp
26#define quantlib_fdm_ext_ou_jump_model_inner_value_hpp
27
28#include <ql/methods/finitedifferences/meshers/fdmmesher.hpp>
29#include <ql/methods/finitedifferences/operators/fdmlinearopiterator.hpp>
30#include <ql/methods/finitedifferences/utilities/fdminnervaluecalculator.hpp>
31#include <ql/payoff.hpp>
32#include <utility>
33
34namespace QuantLib {
35
37 public:
38 typedef std::vector<std::pair<Time, Real> > Shape;
39
40 FdmExtOUJumpModelInnerValue(ext::shared_ptr<Payoff> payoff,
41 ext::shared_ptr<FdmMesher> mesher,
42 ext::shared_ptr<Shape> shape = ext::shared_ptr<Shape>())
43 : payoff_(std::move(payoff)), mesher_(std::move(mesher)), shape_(std::move(shape)) {}
44
45 Real innerValue(const FdmLinearOpIterator& iter, Time t) override {
46 const Real x = mesher_->location(iter, 0);
47 const Real y = mesher_->location(iter, 1);
48
49 Real f = 0;
50 if (shape_ != nullptr) {
51 f = std::lower_bound(shape_->begin(), shape_->end(),
52 std::pair<Time, Real>(t-std::sqrt(QL_EPSILON), 0.0))->second;
53 }
54 return (*payoff_)(std::exp(f + x + y));
55 }
56 Real avgInnerValue(const FdmLinearOpIterator& iter, Time t) override {
57 return innerValue(iter, t);
58 }
59
60 private:
61 const ext::shared_ptr<Payoff> payoff_;
62 const ext::shared_ptr<FdmMesher> mesher_;
63 const ext::shared_ptr<Shape> shape_;
64 };
65}
66
67#endif
Real innerValue(const FdmLinearOpIterator &iter, Time t) override
FdmExtOUJumpModelInnerValue(ext::shared_ptr< Payoff > payoff, ext::shared_ptr< FdmMesher > mesher, ext::shared_ptr< Shape > shape=ext::shared_ptr< Shape >())
std::vector< std::pair< Time, Real > > Shape
Real avgInnerValue(const FdmLinearOpIterator &iter, Time t) override
const ext::shared_ptr< FdmMesher > mesher_
#define QL_EPSILON
Definition: qldefines.hpp:178
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
STL namespace.