/src/quantlib/ql/experimental/volatility/blackvolsurface.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) 2007 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 | | <https://www.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/experimental/volatility/blackvolsurface.hpp> |
21 | | #include <ql/termstructures/volatility/smilesection.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | | BlackVolSurface::BlackVolSurface(BusinessDayConvention bdc, |
26 | | const DayCounter& dc) |
27 | 0 | : BlackAtmVolCurve(bdc, dc) {} |
28 | | |
29 | | BlackVolSurface::BlackVolSurface(const Date& refDate, |
30 | | const Calendar& cal, |
31 | | BusinessDayConvention bdc, |
32 | | const DayCounter& dc) |
33 | 0 | : BlackAtmVolCurve(refDate, cal, bdc, dc) {} |
34 | | |
35 | | BlackVolSurface::BlackVolSurface(Natural settlDays, |
36 | | const Calendar& cal, |
37 | | BusinessDayConvention bdc, |
38 | | const DayCounter& dc) |
39 | 0 | : BlackAtmVolCurve(settlDays, cal, bdc, dc) {} |
40 | | |
41 | 0 | Real BlackVolSurface::atmVarianceImpl(Time t) const { |
42 | 0 | const ext::shared_ptr<SmileSection>& s = smileSectionImpl(t); |
43 | 0 | return s->variance(s->atmLevel()); |
44 | 0 | } |
45 | | |
46 | 0 | Volatility BlackVolSurface::atmVolImpl(Time t) const { |
47 | 0 | const ext::shared_ptr<SmileSection>& s = smileSectionImpl(t); |
48 | 0 | return s->volatility(s->atmLevel()); |
49 | 0 | } |
50 | | |
51 | 0 | void BlackVolSurface::accept(AcyclicVisitor& v) { |
52 | 0 | auto* v1 = dynamic_cast<Visitor<BlackVolSurface>*>(&v); |
53 | 0 | if (v1 != nullptr) |
54 | 0 | v1->visit(*this); |
55 | 0 | else |
56 | 0 | QL_FAIL("not a BlackVolSurface term structure visitor"); |
57 | 0 | } |
58 | | |
59 | | } |