/src/quantlib/ql/experimental/volatility/interestratevolsurface.cpp
Line | Count | Source |
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/interestratevolsurface.hpp> |
21 | | #include <utility> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | | InterestRateVolSurface::InterestRateVolSurface(ext::shared_ptr<InterestRateIndex> index, |
26 | | BusinessDayConvention bdc, |
27 | | const DayCounter& dc) |
28 | 0 | : BlackVolSurface(bdc, dc), index_(std::move(index)) {} |
29 | | |
30 | | InterestRateVolSurface::InterestRateVolSurface(ext::shared_ptr<InterestRateIndex> index, |
31 | | const Date& refDate, |
32 | | const Calendar& cal, |
33 | | BusinessDayConvention bdc, |
34 | | const DayCounter& dc) |
35 | 0 | : BlackVolSurface(refDate, cal, bdc, dc), index_(std::move(index)) {} |
36 | | |
37 | | InterestRateVolSurface::InterestRateVolSurface(ext::shared_ptr<InterestRateIndex> index, |
38 | | Natural settlDays, |
39 | | const Calendar& cal, |
40 | | BusinessDayConvention bdc, |
41 | | const DayCounter& dc) |
42 | 0 | : BlackVolSurface(settlDays, cal, bdc, dc), index_(std::move(index)) {} |
43 | | |
44 | 0 | Date InterestRateVolSurface::optionDateFromTenor(const Period& p) const { |
45 | 0 | ext::shared_ptr<InterestRateIndex> i = index(); |
46 | | // optionlet style |
47 | 0 | Date refDate = i->fixingCalendar().adjust(referenceDate(), Following); |
48 | 0 | Date settlement = i->valueDate(refDate); |
49 | 0 | Date start = settlement+p; |
50 | 0 | return i->fixingDate(start); |
51 | 0 | } |
52 | | |
53 | 0 | void InterestRateVolSurface::accept(AcyclicVisitor& v) { |
54 | 0 | auto* v1 = dynamic_cast<Visitor<InterestRateVolSurface>*>(&v); |
55 | 0 | if (v1 != nullptr) |
56 | 0 | v1->visit(*this); |
57 | 0 | else |
58 | 0 | BlackVolSurface::accept(v); |
59 | 0 | } |
60 | | |
61 | | } |