QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
swaption.hpp
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) 2006 Cristina Duminuco
6 Copyright (C) 2006 Marco Bianchetti
7 Copyright (C) 2007 StatPro Italia srl
8 Copyright (C) 2014 Ferdinando Ametrano
9 Copyright (C) 2016, 2018 Peter Caspers
10
11 This file is part of QuantLib, a free-software/open-source library
12 for financial quantitative analysts and developers - http://quantlib.org/
13
14 QuantLib is free software: you can redistribute it and/or modify it
15 under the terms of the QuantLib license. You should have received a
16 copy of the license along with this program; if not, please email
17 <quantlib-dev@lists.sf.net>. The license is also available online at
18 <http://quantlib.org/license.shtml>.
19
20 This program is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
22 FOR A PARTICULAR PURPOSE. See the license for more details.
23*/
24
29#ifndef quantlib_instruments_swaption_hpp
30#define quantlib_instruments_swaption_hpp
31
32#include <ql/option.hpp>
33#include <ql/instruments/vanillaswap.hpp>
34#include <ql/termstructures/yieldtermstructure.hpp>
35#include <ql/termstructures/volatility/volatilitytype.hpp>
36
37namespace QuantLib {
38
40 struct Settlement {
41 enum Type { Physical, Cash };
42 enum Method {
47 };
51 };
52
53 std::ostream& operator<<(std::ostream& out,
54 Settlement::Type type);
55
56 std::ostream& operator<<(std::ostream& out,
57 Settlement::Method method);
58
60
81 class Swaption : public Option {
82 public:
83 class arguments;
84 class engine;
85 Swaption(ext::shared_ptr<VanillaSwap> swap,
86 const ext::shared_ptr<Exercise>& exercise,
90
91 void deepUpdate() override;
93
95 bool isExpired() const override;
96 void setupArguments(PricingEngine::arguments*) const override;
98
102 return settlementMethod_;
103 }
104 Swap::Type type() const { return swap_->type(); }
105 const ext::shared_ptr<VanillaSwap>& underlyingSwap() const {
106 return swap_;
107 }
109
111 Real price,
112 const Handle<YieldTermStructure>& discountCurve,
113 Volatility guess,
114 Real accuracy = 1.0e-4,
115 Natural maxEvaluations = 100,
116 Volatility minVol = 1.0e-7,
117 Volatility maxVol = 4.0,
119 Real displacement = 0.0) const;
120 private:
121 // arguments
122 ext::shared_ptr<VanillaSwap> swap_;
123 //Handle<YieldTermStructure> termStructure_;
126 };
127
129 class Swaption::arguments : public VanillaSwap::arguments,
130 public Option::arguments {
131 public:
132 arguments() = default;
133 ext::shared_ptr<VanillaSwap> swap;
136 void validate() const override;
137 };
138
141 : public GenericEngine<Swaption::arguments, Swaption::results> {};
142
143}
144
145#endif
template base class for option pricing engines
Shared handle to an observable.
Definition: handle.hpp:41
basic option arguments
Definition: option.hpp:57
base option class
Definition: option.hpp:36
ext::shared_ptr< Exercise > exercise() const
Definition: option.hpp:46
Arguments for swaption calculation
Definition: swaption.hpp:130
Settlement::Method settlementMethod
Definition: swaption.hpp:135
ext::shared_ptr< VanillaSwap > swap
Definition: swaption.hpp:133
Settlement::Type settlementType
Definition: swaption.hpp:134
void validate() const override
Definition: swaption.cpp:174
base class for swaption engines
Definition: swaption.hpp:141
Swaption class
Definition: swaption.hpp:81
void setupArguments(PricingEngine::arguments *) const override
Definition: swaption.cpp:160
Settlement::Type settlementType() const
Definition: swaption.hpp:100
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Definition: swaption.cpp:156
ext::shared_ptr< VanillaSwap > swap_
Definition: swaption.hpp:122
void deepUpdate() override
Definition: swaption.cpp:151
const ext::shared_ptr< VanillaSwap > & underlyingSwap() const
Definition: swaption.hpp:105
Swap::Type type() const
Definition: swaption.hpp:104
Settlement::Method settlementMethod_
Definition: swaption.hpp:125
Volatility impliedVolatility(Real price, const Handle< YieldTermStructure > &discountCurve, Volatility guess, Real accuracy=1.0e-4, Natural maxEvaluations=100, Volatility minVol=1.0e-7, Volatility maxVol=4.0, VolatilityType type=ShiftedLognormal, Real displacement=0.0) const
implied volatility
Definition: swaption.cpp:182
Settlement::Method settlementMethod() const
Definition: swaption.hpp:101
Settlement::Type settlementType_
Definition: swaption.hpp:124
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
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
void swap(Array &v, Array &w) noexcept
Definition: array.hpp:903
settlement information
Definition: swaption.hpp:40
static void checkTypeAndMethodConsistency(Settlement::Type, Settlement::Method)
check consistency of settlement type and method
Definition: swaption.cpp:201