Coverage Report

Created: 2025-08-05 06:45

/src/quantlib/ql/termstructures/volatility/equityfx/localvoltermstructure.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) 2002, 2003 Ferdinando Ametrano
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
 <http://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
#include <ql/termstructures/volatility/equityfx/localvoltermstructure.hpp>
21
22
namespace QuantLib {
23
24
    LocalVolTermStructure::LocalVolTermStructure(BusinessDayConvention bdc,
25
                                                 const DayCounter& dc)
26
0
    : VolatilityTermStructure(bdc, dc) {}
27
28
    LocalVolTermStructure::LocalVolTermStructure(const Date& referenceDate,
29
                                                 const Calendar& cal,
30
                                                 BusinessDayConvention bdc,
31
                                                 const DayCounter& dc)
32
0
    : VolatilityTermStructure(referenceDate, cal, bdc, dc) {}
33
34
    LocalVolTermStructure::LocalVolTermStructure(Natural settlementDays,
35
                                                 const Calendar& cal,
36
                                                 BusinessDayConvention bdc,
37
                                                 const DayCounter& dc)
38
0
    : VolatilityTermStructure(settlementDays, cal, bdc, dc) {}
39
40
    Volatility LocalVolTermStructure::localVol(const Date& d,
41
                                               Real underlyingLevel,
42
0
                                               bool extrapolate) const {
43
0
        checkRange(d, extrapolate);
44
0
        checkStrike(underlyingLevel, extrapolate);
45
0
        Time t = timeFromReference(d);
46
0
        return localVolImpl(t, underlyingLevel);
47
0
    }
48
49
    Volatility LocalVolTermStructure::localVol(Time t,
50
                                               Real underlyingLevel,
51
0
                                               bool extrapolate) const {
52
0
        checkRange(t, extrapolate);
53
0
        checkStrike(underlyingLevel, extrapolate);
54
0
        return localVolImpl(t, underlyingLevel);
55
0
    }
56
57
0
    void LocalVolTermStructure::accept(AcyclicVisitor& v) {
58
0
        auto* v1 = dynamic_cast<Visitor<LocalVolTermStructure>*>(&v);
59
0
        if (v1 != nullptr)
60
0
            v1->visit(*this);
61
0
        else
62
0
            QL_FAIL("not a local-volatility term structure visitor");
63
0
    }
64
65
}