• 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

88.89
/ql/termstructures/volatility/optionlet/constantoptionletvol.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) 2004, 2005, 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/optionlet/constantoptionletvol.hpp>
25
#include <utility>
26

27
namespace QuantLib {
28

29
    // floating reference date, floating market data
30
    ConstantOptionletVolatility::ConstantOptionletVolatility(Natural settlementDays,
100,441✔
31
                                                             const Calendar& cal,
32
                                                             BusinessDayConvention bdc,
33
                                                             Handle<Quote> vol,
34
                                                             const DayCounter& dc,
35
                                                             VolatilityType type,
36
                                                             Real displacement)
100,441✔
37
    : OptionletVolatilityStructure(settlementDays, cal, bdc, dc), volatility_(std::move(vol)),
38
      type_(type), displacement_(displacement) {
100,441✔
39
        registerWith(volatility_);
100,441✔
40
    }
100,441✔
41

42
    // fixed reference date, floating market data
43
    ConstantOptionletVolatility::ConstantOptionletVolatility(const Date& referenceDate,
7✔
44
                                                             const Calendar& cal,
45
                                                             BusinessDayConvention bdc,
46
                                                             Handle<Quote> vol,
47
                                                             const DayCounter& dc,
48
                                                             VolatilityType type,
49
                                                             Real displacement)
7✔
50
    : OptionletVolatilityStructure(referenceDate, cal, bdc, dc), volatility_(std::move(vol)),
51
      type_(type), displacement_(displacement) {
7✔
52
        registerWith(volatility_);
7✔
53
    }
7✔
54

55
    // floating reference date, fixed market data
56
    ConstantOptionletVolatility::ConstantOptionletVolatility(
777✔
57
        Natural settlementDays, const Calendar &cal, BusinessDayConvention bdc,
58
        Volatility vol, const DayCounter &dc, VolatilityType type,
59
        Real displacement)
777✔
60
        : OptionletVolatilityStructure(settlementDays, cal, bdc, dc),
61
          volatility_(ext::make_shared<SimpleQuote>(vol)),
1,554✔
62
          type_(type), displacement_(displacement) {}
1,554✔
63

64
    // fixed reference date, fixed market data
65
    ConstantOptionletVolatility::ConstantOptionletVolatility(
18✔
66
        const Date &referenceDate, const Calendar &cal,
67
        BusinessDayConvention bdc, Volatility vol, const DayCounter &dc,
68
        VolatilityType type, Real displacement)
18✔
69
        : OptionletVolatilityStructure(referenceDate, cal, bdc, dc),
70
          volatility_(ext::make_shared<SimpleQuote>(vol)),
36✔
71
          type_(type), displacement_(displacement) {}
36✔
72

73
    ext::shared_ptr<SmileSection>
74
    ConstantOptionletVolatility::smileSectionImpl(const Date& d) const {
20✔
75
        Volatility atmVol = volatility_->value();
20✔
76
        return ext::make_shared<FlatSmileSection>(
20✔
77
            d, atmVol, dayCounter(), referenceDate());
40✔
78
    }
79

80
    ext::shared_ptr<SmileSection>
81
    ConstantOptionletVolatility::smileSectionImpl(Time optionTime) const {
×
82
        Volatility atmVol = volatility_->value();
×
NEW
83
        return ext::make_shared<FlatSmileSection>(optionTime, atmVol, dayCounter());
×
84
    }
85

86
    Volatility ConstantOptionletVolatility::volatilityImpl(Time,
1,236,239✔
87
                                                    Rate) const {
88
        return volatility_->value();
1,236,239✔
89
    }
90

91
}
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