Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/termstructures/volatility/optionlet/spreadedoptionletvol.cpp
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) 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
 <http://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/optionlet/spreadedoptionletvol.hpp>
23
#include <ql/termstructures/volatility/spreadedsmilesection.hpp>
24
#include <utility>
25
26
namespace QuantLib {
27
28
    SpreadedOptionletVolatility::SpreadedOptionletVolatility(
29
        const Handle<OptionletVolatilityStructure>& baseVol, Handle<Quote> spread)
30
0
    : baseVol_(baseVol), spread_(std::move(spread)) {
31
0
        enableExtrapolation(baseVol->allowsExtrapolation());
32
0
        registerWith(baseVol_);
33
0
        registerWith(spread_);
34
0
    }
Unexecuted instantiation: QuantLib::SpreadedOptionletVolatility::SpreadedOptionletVolatility(QuantLib::Handle<QuantLib::OptionletVolatilityStructure> const&, QuantLib::Handle<QuantLib::Quote>)
Unexecuted instantiation: QuantLib::SpreadedOptionletVolatility::SpreadedOptionletVolatility(QuantLib::Handle<QuantLib::OptionletVolatilityStructure> const&, QuantLib::Handle<QuantLib::Quote>)
35
36
    ext::shared_ptr<SmileSection>
37
0
    SpreadedOptionletVolatility::smileSectionImpl(const Date& d) const {
38
0
        ext::shared_ptr<SmileSection> baseSmile =
39
0
            baseVol_->smileSection(d, true);
40
0
        return ext::shared_ptr<SmileSection>(new
41
0
            SpreadedSmileSection(baseSmile, spread_));
42
0
    }
43
44
    ext::shared_ptr<SmileSection>
45
0
    SpreadedOptionletVolatility::smileSectionImpl(Time optionTime) const {
46
0
        ext::shared_ptr<SmileSection> baseSmile =
47
0
            baseVol_->smileSection(optionTime, true);
48
0
        return ext::shared_ptr<SmileSection>(new
49
0
            SpreadedSmileSection(baseSmile, spread_));
50
0
    }
51
52
    Volatility SpreadedOptionletVolatility::volatilityImpl(Time t,
53
0
                                                           Rate s) const {
54
0
        return baseVol_->volatility(t, s, true) + spread_->value();
55
0
    }
56
57
}