Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/pricingengines/barrier/discretizedbarrieroption.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2014 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 discretizedbarrieroption.hpp
21
    \brief discretized barrier option
22
*/
23
24
#ifndef quantlib_discretized_barrier_option_h
25
#define quantlib_discretized_barrier_option_h
26
27
#include <ql/discretizedasset.hpp>
28
#include <ql/methods/lattices/bsmlattice.hpp>
29
#include <ql/instruments/barrieroption.hpp>
30
#include <ql/pricingengines/vanilla/discretizedvanillaoption.hpp>
31
32
namespace QuantLib {
33
34
    class DiscretizedBarrierOption : public DiscretizedAsset {
35
      public:
36
        DiscretizedBarrierOption(const BarrierOption::arguments&,
37
                                 const StochasticProcess& process,
38
                                 const TimeGrid& grid = TimeGrid());
39
40
        void reset(Size size) override;
41
42
0
        const Array& vanilla() const { 
43
0
            return vanilla_.values(); 
44
0
        }
45
46
0
        const BarrierOption::arguments& arguments() const {
47
0
           return arguments_;
48
0
        }
49
50
0
        std::vector<Time> mandatoryTimes() const override { return stoppingTimes_; }
51
52
        void checkBarrier(Array &optvalues, const Array &grid) const;
53
      protected:
54
        void postAdjustValuesImpl() override;
55
56
      private:
57
        BarrierOption::arguments arguments_;
58
        std::vector<Time> stoppingTimes_;
59
        DiscretizedVanillaOption vanilla_; 
60
    };
61
62
    class DiscretizedDermanKaniBarrierOption : public DiscretizedAsset {
63
      public:
64
        DiscretizedDermanKaniBarrierOption(const BarrierOption::arguments&,
65
                                 const StochasticProcess& process,
66
                                 const TimeGrid& grid = TimeGrid());
67
68
        void reset(Size size) override;
69
70
0
        std::vector<Time> mandatoryTimes() const override { return unenhanced_.mandatoryTimes(); }
71
72
      protected:
73
        void postAdjustValuesImpl() override;
74
75
      private:
76
        void adjustBarrier(Array &optvalues, const Array &grid);
77
        DiscretizedBarrierOption unenhanced_;
78
    };
79
}
80
81
82
83
84
85
#endif