• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lballabio / QuantLib / 27081312717

07 Jun 2026 03:17AM UTC coverage: 74.801% (+0.004%) from 74.797%
27081312717

Pull #2619

github

web-flow
Merge d8f820f5b into 5111c3a14
Pull Request #2619: Use make_shared in volatility-related code

54 of 72 new or added lines in 22 files covered. (75.0%)

1 existing line in 1 file now uncovered.

59143 of 79067 relevant lines covered (74.8%)

8576610.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.97
/ql/termstructures/volatility/swaption/swaptionconstantvol.cpp
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2

3
/*
4
 Copyright (C) 2008 Ferdinando Ametrano
5
 Copyright (C) 2006, 2007 StatPro Italia srl
6
 Copyright (C) 2015 Peter Caspers
7

8
 This file is part of QuantLib, a free-software/open-source library
9
 for financial quantitative analysts and developers - http://quantlib.org/
10

11
 QuantLib is free software: you can redistribute it and/or modify it
12
 under the terms of the QuantLib license.  You should have received a
13
 copy of the license along with this program; if not, please email
14
 <quantlib-dev@lists.sf.net>. The license is also available online at
15
 <https://www.quantlib.org/license.shtml>.
16

17
 This program is distributed in the hope that it will be useful, but WITHOUT
18
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 FOR A PARTICULAR PURPOSE.  See the license for more details.
20
*/
21

22
#include <ql/quotes/simplequote.hpp>
23
#include <ql/termstructures/volatility/flatsmilesection.hpp>
24
#include <ql/termstructures/volatility/swaption/swaptionconstantvol.hpp>
25
#include <utility>
26

27
namespace QuantLib {
28

29
    // floating reference date, floating market data
30
    ConstantSwaptionVolatility::ConstantSwaptionVolatility(Natural settlementDays,
391,642✔
31
                                                           const Calendar& cal,
32
                                                           BusinessDayConvention bdc,
33
                                                           Handle<Quote> vol,
34
                                                           const DayCounter& dc,
35
                                                           const VolatilityType type,
36
                                                           const Real shift)
391,642✔
37
    : SwaptionVolatilityStructure(settlementDays, cal, bdc, dc), volatility_(std::move(vol)),
38
      maxSwapTenor_(100 * Years), volatilityType_(type), shift_(shift) {
391,642✔
39
        registerWith(volatility_);
391,642✔
40
    }
391,642✔
41

42
    // fixed reference date, floating market data
43
    ConstantSwaptionVolatility::ConstantSwaptionVolatility(const Date& referenceDate,
×
44
                                                           const Calendar& cal,
45
                                                           BusinessDayConvention bdc,
46
                                                           Handle<Quote> vol,
47
                                                           const DayCounter& dc,
48
                                                           const VolatilityType type,
49
                                                           const Real shift)
×
50
    : SwaptionVolatilityStructure(referenceDate, cal, bdc, dc), volatility_(std::move(vol)),
51
      maxSwapTenor_(100 * Years), volatilityType_(type), shift_(shift) {
×
52
        registerWith(volatility_);
×
53
    }
×
54

55
    // floating reference date, fixed market data
56
    ConstantSwaptionVolatility::ConstantSwaptionVolatility(
15✔
57
                                                    Natural settlementDays,
58
                                                    const Calendar& cal,
59
                                                    BusinessDayConvention bdc,
60
                                                    Volatility vol,
61
                                                    const DayCounter& dc,
62
                                                    const VolatilityType type,
63
                                                    const Real shift)
15✔
64
    : SwaptionVolatilityStructure(settlementDays, cal, bdc, dc),
65
      volatility_(ext::make_shared<SimpleQuote>(vol)),
30✔
66
      maxSwapTenor_(100*Years), volatilityType_(type), shift_(shift) {}
30✔
67

68
    // fixed reference date, fixed market data
69
    ConstantSwaptionVolatility::ConstantSwaptionVolatility(
15✔
70
                                                    const Date& referenceDate,
71
                                                    const Calendar& cal,
72
                                                    BusinessDayConvention bdc,
73
                                                    Volatility vol,
74
                                                    const DayCounter& dc,
75
                                                    const VolatilityType type,
76
                                                    const Real shift)
15✔
77
    : SwaptionVolatilityStructure(referenceDate, cal, bdc, dc),
78
      volatility_(ext::make_shared<SimpleQuote>(vol)),
30✔
79
      maxSwapTenor_(100*Years), volatilityType_(type), shift_(shift) {}
30✔
80

81
    ext::shared_ptr<SmileSection>
82
    ConstantSwaptionVolatility::smileSectionImpl(const Date& d,
363✔
83
                                                 const Period&) const {
84
        Volatility atmVol = volatility_->value();
363✔
85
        return ext::make_shared<FlatSmileSection>(
363✔
86
            d, atmVol, dayCounter(), referenceDate(), Null<Rate>(),
363✔
87
            volatilityType_, shift_);
726✔
88
    }
89

90
    ext::shared_ptr<SmileSection>
91
    ConstantSwaptionVolatility::smileSectionImpl(Time optionTime,
×
92
                                                 Time) const {
93
        Volatility atmVol = volatility_->value();
×
NEW
94
        return ext::make_shared<FlatSmileSection>(
×
NEW
95
            optionTime, atmVol, dayCounter(), Null<Rate>(), volatilityType_, shift_);
×
96
    }
97

98
    Volatility ConstantSwaptionVolatility::volatilityImpl(const Date&,
518✔
99
                                                          const Period&,
100
                                                          Rate) const {
101
        return volatility_->value();
518✔
102
    }
103

104
    Volatility ConstantSwaptionVolatility::volatilityImpl(Time,
616,937✔
105
                                                          Time,
106
                                                          Rate) const {
107
        return volatility_->value();
616,937✔
108
    }
109

110
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc