Coverage Report

Created: 2025-11-04 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/experimental/volatility/noarbsabrsmilesection.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2014 Peter Caspers
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 noarbsabrsmilesection.hpp
21
    \brief no arbitrage sabr smile section
22
*/
23
24
#ifndef quantlib_noarbsabr_smile_section_hpp
25
#define quantlib_noarbsabr_smile_section_hpp
26
27
#include <ql/termstructures/volatility/smilesection.hpp>
28
#include <ql/time/daycounters/actual365fixed.hpp>
29
#include <ql/experimental/volatility/noarbsabr.hpp>
30
#include <vector>
31
32
namespace QuantLib {
33
34
class NoArbSabrSmileSection : public SmileSection {
35
36
  public:
37
    NoArbSabrSmileSection(Time timeToExpiry,
38
                          Rate forward,
39
                          std::vector<Real> sabrParameters,
40
                          Real shift = 0.0,
41
                          VolatilityType volatilityType = VolatilityType::ShiftedLognormal);
42
    NoArbSabrSmileSection(const Date& d,
43
                          Rate forward,
44
                          std::vector<Real> sabrParameters,
45
                          const DayCounter& dc = Actual365Fixed(),
46
                          Real shift = 0.0,
47
                          VolatilityType volatilityType = VolatilityType::ShiftedLognormal);
48
0
    Real minStrike() const override { return 0.0; }
49
0
    Real maxStrike() const override { return QL_MAX_REAL; }
50
0
    Real atmLevel() const override { return forward_; }
51
    Real
52
    optionPrice(Rate strike, Option::Type type = Option::Call, Real discount = 1.0) const override;
53
    Real digitalOptionPrice(Rate strike,
54
                            Option::Type type = Option::Call,
55
                            Real discount = 1.0,
56
                            Real gap = 1.0e-5) const override;
57
    Real density(Rate strike, Real discount = 1.0, Real gap = 1.0E-4) const override;
58
59
0
    ext::shared_ptr<NoArbSabrModel> model() { return model_; }
60
61
  protected:
62
    Volatility volatilityImpl(Rate strike) const override;
63
64
  private:
65
    void init();
66
    ext::shared_ptr<NoArbSabrModel> model_;
67
    Rate forward_;
68
    std::vector<Real> params_;
69
    Real shift_;
70
};
71
}
72
73
#endif