QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
spreadedswaptionvol.cpp
Go to the documentation of this file.
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>
24#include <utility>
25
26namespace QuantLib {
27
30 : SwaptionVolatilityStructure(baseVol->businessDayConvention(), baseVol->dayCounter()),
31 baseVol_(baseVol), spread_(std::move(spread)) {
32 enableExtrapolation(baseVol->allowsExtrapolation());
35 }
36
37 ext::shared_ptr<SmileSection>
39 const Period& swapT) const {
40 ext::shared_ptr<SmileSection> baseSmile =
41 baseVol_->smileSection(d, swapT, true);
42 return ext::shared_ptr<SmileSection>(new
43 SpreadedSmileSection(baseSmile, spread_));
44 }
45
46 ext::shared_ptr<SmileSection>
48 Time swapLength) const {
49 ext::shared_ptr<SmileSection> baseSmile =
50 baseVol_->smileSection(optionTime, swapLength, true);
51 return ext::shared_ptr<SmileSection>(new
52 SpreadedSmileSection(baseSmile, spread_));
53 }
54
56 const Period& p,
57 Rate strike) const {
58 return baseVol_->volatility(d, p, strike, true) + spread_->value();
59 }
60
62 Time l,
63 Rate strike) const {
64 return baseVol_->volatility(t, l, strike, true) + spread_->value();
65 }
66
67}
Concrete date class.
Definition: date.hpp:125
void enableExtrapolation(bool b=true)
enable extrapolation in subsequent calls
Shared handle to an observable.
Definition: handle.hpp:41
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Volatility volatilityImpl(const Date &optionDate, const Period &swapTenor, Rate strike) const override
ext::shared_ptr< SmileSection > smileSectionImpl(const Date &optionDate, const Period &swapTenor) const override
const Handle< SwaptionVolatilityStructure > baseVol_
SpreadedSwaptionVolatility(const Handle< SwaptionVolatilityStructure > &, Handle< Quote > spread)
Time swapLength(const Period &swapTenor) const
implements the conversion between swap tenor and swap (time) length
const DefaultType & t
Date d
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.
purely virtual base class for market observables
Spreaded SmileSection class.
Spreaded swaption volatility.