QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
swaptionhelper.hpp
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) 2001, 2002, 2003 Sadruddin Rejeb
5 Copyright (C) 2015 Peter Caspers
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/*! \file swaptionhelper.hpp
22 \brief Swaption calibration helper
23*/
24
25#ifndef quantlib_swaption_calibration_helper_hpp
26#define quantlib_swaption_calibration_helper_hpp
27
32
33namespace QuantLib {
34
35 //! calibration helper for interest-rate swaptions
36 /*! \warning passing an overnight index to the constructor will
37 result in an overnight-indexed swap being built, but
38 model-based engines will treat it as a vanilla swap.
39 This is at best a decent proxy, at worst simply wrong.
40 Use with caution.
41 */
43 public:
44 SwaptionHelper(const Period& maturity,
45 const Period& length,
47 ext::shared_ptr<IborIndex> index,
48 const Period& fixedLegTenor,
49 DayCounter fixedLegDayCounter,
50 DayCounter floatingLegDayCounter,
51 Handle<YieldTermStructure> termStructure,
53 Real strike = Null<Real>(),
54 Real nominal = 1.0,
56 Real shift = 0.0,
57 Natural settlementDays = Null<Size>(),
59
60 SwaptionHelper(const Date& exerciseDate,
61 const Period& length,
63 ext::shared_ptr<IborIndex> index,
64 const Period& fixedLegTenor,
65 DayCounter fixedLegDayCounter,
66 DayCounter floatingLegDayCounter,
67 Handle<YieldTermStructure> termStructure,
69 Real strike = Null<Real>(),
70 Real nominal = 1.0,
72 Real shift = 0.0,
73 Natural settlementDays = Null<Size>(),
75
76 SwaptionHelper(const Date& exerciseDate,
77 const Date& endDate,
79 ext::shared_ptr<IborIndex> index,
80 const Period& fixedLegTenor,
81 DayCounter fixedLegDayCounter,
82 DayCounter floatingLegDayCounter,
83 Handle<YieldTermStructure> termStructure,
85 Real strike = Null<Real>(),
86 Real nominal = 1.0,
88 Real shift = 0.0,
89 Natural settlementDays = Null<Size>(),
91
92 void addTimesTo(std::list<Time>& times) const override;
93 Real modelValue() const override;
94 Real blackPrice(Volatility volatility) const override;
95
96 const ext::shared_ptr<FixedVsFloatingSwap>& underlying() const {
97 calculate();
98 return swap_;
99 }
100 /*! \deprecated Use the SwaptionHelper::underlying method instead.
101 Deprecated in version 1.34.
102 */
103 [[deprecated("Use the SwaptionHelper::underlying method instead")]]
104 ext::shared_ptr<VanillaSwap> underlyingSwap() const {
105 calculate();
106 auto vanilla = ext::dynamic_pointer_cast<VanillaSwap>(swap_);
107 QL_REQUIRE(vanilla, "underlying is not a vanilla swap");
108 return vanilla;
109 }
110 ext::shared_ptr<Swaption> swaption() const { calculate(); return swaption_; }
111
112 private:
113 void performCalculations() const override;
114 ext::shared_ptr<FixedVsFloatingSwap> makeSwap(Schedule fixedSchedule,
115 Schedule floatSchedule,
116 Rate exerciseRate,
117 Swap::Type type) const;
120 const ext::shared_ptr<IborIndex> index_;
127 mutable ext::shared_ptr<FixedVsFloatingSwap> swap_;
128 mutable ext::shared_ptr<Swaption> swaption_;
129 };
130
131}
132
133#endif
Calibration helper class.
liquid Black76 market instrument used during calibration
Handle< Quote > volatility() const
returns the volatility Handle
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
virtual void calculate() const
Definition: lazyobject.hpp:253
template class providing a null value for a given type.
Definition: null.hpp:76
Payment schedule.
Definition: schedule.hpp:40
calibration helper for interest-rate swaptions
ext::shared_ptr< Swaption > swaption_
void performCalculations() const override
ext::shared_ptr< FixedVsFloatingSwap > makeSwap(Schedule fixedSchedule, Schedule floatSchedule, Rate exerciseRate, Swap::Type type) const
ext::shared_ptr< VanillaSwap > underlyingSwap() const
const ext::shared_ptr< IborIndex > index_
Real blackPrice(Volatility volatility) const override
Black or Bachelier price given a volatility.
ext::shared_ptr< Swaption > swaption() const
Real modelValue() const override
returns the price of the instrument according to the model
void addTimesTo(std::list< Time > &times) const override
const ext::shared_ptr< FixedVsFloatingSwap > & underlying() const
ext::shared_ptr< FixedVsFloatingSwap > swap_
const DayCounter floatingLegDayCounter_
const Handle< YieldTermStructure > termStructure_
const DayCounter fixedLegDayCounter_
const RateAveraging::Type averagingMethod_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
rate-averaging method
Swaption class.
volatility types