/src/quantlib/ql/experimental/barrieroption/discretizeddoublebarrieroption.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2015 Thema Consulting SA |
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 discretizeddoublebarrieroption.hpp |
21 | | \brief discretized double barrier option |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_discretized_double_barrier_option_h |
25 | | #define quantlib_discretized_double_barrier_option_h |
26 | | |
27 | | #include <ql/discretizedasset.hpp> |
28 | | #include <ql/methods/lattices/bsmlattice.hpp> |
29 | | #include <ql/instruments/doublebarrieroption.hpp> |
30 | | #include <ql/pricingengines/vanilla/discretizedvanillaoption.hpp> |
31 | | |
32 | | namespace QuantLib { |
33 | | |
34 | | //! Standard discretized option helper class |
35 | | /*! This class is used with the BinomialDoubleBarrierEngine to |
36 | | implement a standard binomial algorithm for double barrier |
37 | | options |
38 | | */ |
39 | | class DiscretizedDoubleBarrierOption : public DiscretizedAsset { |
40 | | public: |
41 | | DiscretizedDoubleBarrierOption(const DoubleBarrierOption::arguments&, |
42 | | const StochasticProcess& process, |
43 | | const TimeGrid& grid = TimeGrid()); |
44 | | |
45 | | void reset(Size size) override; |
46 | | |
47 | 0 | const Array& vanilla() const { |
48 | 0 | return vanilla_.values(); |
49 | 0 | } |
50 | | |
51 | 0 | const DoubleBarrierOption::arguments& arguments() const { |
52 | 0 | return arguments_; |
53 | 0 | } |
54 | | |
55 | 0 | std::vector<Time> mandatoryTimes() const override { return stoppingTimes_; } |
56 | | |
57 | | void checkBarrier(Array &optvalues, const Array &grid) const; |
58 | | protected: |
59 | | void postAdjustValuesImpl() override; |
60 | | |
61 | | private: |
62 | | DoubleBarrierOption::arguments arguments_; |
63 | | std::vector<Time> stoppingTimes_; |
64 | | DiscretizedVanillaOption vanilla_; |
65 | | }; |
66 | | |
67 | | //! Derman-Kani-Ergener-Bardhan discretized option helper class |
68 | | /*! This class is used with the BinomialDoubleBarrierEngine to |
69 | | implement the enhanced binomial algorithm of E.Derman, I.Kani, |
70 | | D.Ergener, I.Bardhan ("Enhanced Numerical Methods for Options with |
71 | | Barriers", 1995) |
72 | | |
73 | | \note This algorithm is only suitable if the payoff can be approximated |
74 | | linearly, e.g. is not usable for cash-or-nothing payoffs. |
75 | | */ |
76 | | class DiscretizedDermanKaniDoubleBarrierOption : public DiscretizedAsset { |
77 | | public: |
78 | | DiscretizedDermanKaniDoubleBarrierOption(const DoubleBarrierOption::arguments&, |
79 | | const StochasticProcess& process, |
80 | | const TimeGrid& grid = TimeGrid()); |
81 | | |
82 | | void reset(Size size) override; |
83 | | |
84 | 0 | std::vector<Time> mandatoryTimes() const override { return unenhanced_.mandatoryTimes(); } |
85 | | |
86 | | protected: |
87 | | void postAdjustValuesImpl() override; |
88 | | |
89 | | private: |
90 | | void adjustBarrier(Array &optvalues, const Array &grid); |
91 | | DiscretizedDoubleBarrierOption unenhanced_; |
92 | | }; |
93 | | } |
94 | | |
95 | | #endif |