Coverage Report

Created: 2026-06-08 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/termstructures/volatility/swaption/spreadedswaptionvol.cpp
Line
Count
Source
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) 2007 Giorgio Facchinetti
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <https://www.quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
#include <ql/quote.hpp>
22
#include <ql/termstructures/volatility/spreadedsmilesection.hpp>
23
#include <ql/termstructures/volatility/swaption/spreadedswaptionvol.hpp>
24
#include <utility>
25
26
namespace QuantLib {
27
28
    SpreadedSwaptionVolatility::SpreadedSwaptionVolatility(
29
        const Handle<SwaptionVolatilityStructure>& baseVol, Handle<Quote> spread)
30
0
    : SwaptionVolatilityStructure(baseVol->businessDayConvention(), baseVol->dayCounter()),
31
0
      baseVol_(baseVol), spread_(std::move(spread)) {
32
0
        enableExtrapolation(baseVol->allowsExtrapolation());
33
0
        registerWith(baseVol_);
34
0
        registerWith(spread_);
35
0
    }
Unexecuted instantiation: QuantLib::SpreadedSwaptionVolatility::SpreadedSwaptionVolatility(QuantLib::Handle<QuantLib::SwaptionVolatilityStructure> const&, QuantLib::Handle<QuantLib::Quote>)
Unexecuted instantiation: QuantLib::SpreadedSwaptionVolatility::SpreadedSwaptionVolatility(QuantLib::Handle<QuantLib::SwaptionVolatilityStructure> const&, QuantLib::Handle<QuantLib::Quote>)
36
37
    ext::shared_ptr<SmileSection>
38
    SpreadedSwaptionVolatility::smileSectionImpl(const Date& d,
39
0
                                                 const Period& swapT) const {
40
0
        ext::shared_ptr<SmileSection> baseSmile =
41
0
            baseVol_->smileSection(d, swapT, true);
42
0
        return ext::shared_ptr<SmileSection>(new
43
0
            SpreadedSmileSection(baseSmile, spread_));
44
0
    }
45
46
    ext::shared_ptr<SmileSection>
47
    SpreadedSwaptionVolatility::smileSectionImpl(Time optionTime,
48
0
                                                 Time swapLength) const {
49
0
        ext::shared_ptr<SmileSection> baseSmile =
50
0
            baseVol_->smileSection(optionTime, swapLength, true);
51
0
        return ext::shared_ptr<SmileSection>(new
52
0
            SpreadedSmileSection(baseSmile, spread_));
53
0
    }
54
55
    Volatility SpreadedSwaptionVolatility::volatilityImpl(const Date& d,
56
                                                          const Period& p,
57
0
                                                          Rate strike) const {
58
0
        return baseVol_->volatility(d, p, strike, true) + spread_->value();
59
0
    }
60
61
    Volatility SpreadedSwaptionVolatility::volatilityImpl(Time t,
62
                                                          Time l,
63
0
                                                          Rate strike) const {
64
0
        return baseVol_->volatility(t, l, strike, true) + spread_->value();
65
0
    }
66
67
}