Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/termstructures/volatility/flatsmilesection.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) 2007 Ferdinando Ametrano
5
 Copyright (C) 2007 François du Vignaud
6
 Copyright (C) 2007 Giorgio Facchinetti
7
 Copyright (C) 2015 Peter Caspers
8
9
 This file is part of QuantLib, a free-software/open-source library
10
 for financial quantitative analysts and developers - http://quantlib.org/
11
12
 QuantLib is free software: you can redistribute it and/or modify it
13
 under the terms of the QuantLib license.  You should have received a
14
 copy of the license along with this program; if not, please email
15
 <quantlib-dev@lists.sf.net>. The license is also available online at
16
 <https://www.quantlib.org/license.shtml>.
17
18
 This program is distributed in the hope that it will be useful, but WITHOUT
19
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20
 FOR A PARTICULAR PURPOSE.  See the license for more details.
21
*/
22
23
/*! \file flatsmilesection.hpp
24
    \brief Flat SmileSection
25
*/
26
27
#ifndef quantlib_flat_smile_section_hpp
28
#define quantlib_flat_smile_section_hpp
29
30
#include <ql/termstructures/volatility/smilesection.hpp>
31
32
namespace QuantLib {
33
34
    class FlatSmileSection : public SmileSection {
35
      public:
36
        FlatSmileSection(const Date& d,
37
                         Volatility vol,
38
                         const DayCounter& dc,
39
                         const Date& referenceDate = Date(),
40
                         Real atmLevel = Null<Rate>(),
41
                         VolatilityType type = ShiftedLognormal,
42
                         Real shift = 0.0);
43
        FlatSmileSection(Time exerciseTime,
44
                         Volatility vol,
45
                         const DayCounter& dc,
46
                         Real atmLevel = Null<Rate>(),
47
                         VolatilityType type = ShiftedLognormal,
48
                         Real shift = 0.0);
49
        //@{
50
        Real minStrike() const override;
51
        Real maxStrike() const override;
52
        Real atmLevel() const override;
53
        //@}
54
      protected:
55
        Volatility volatilityImpl(Rate) const override;
56
57
      private:
58
        Volatility vol_;
59
        Real atmLevel_;
60
    };
61
62
0
    inline Real FlatSmileSection::minStrike () const {
63
0
        return QL_MIN_REAL - shift();
64
0
    }
65
66
0
    inline Real FlatSmileSection::maxStrike () const {
67
0
        return QL_MAX_REAL;
68
0
    }
69
70
0
    inline Real FlatSmileSection::atmLevel() const {
71
0
        return atmLevel_;
72
0
    }
73
74
0
    inline Volatility FlatSmileSection::volatilityImpl(Rate) const {
75
0
        return vol_;
76
0
    }
77
78
}
79
80
#endif