QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
haganirregularswaptionengine.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) 2011, 2012 Andre Miemiec
5 Copyright (C) 2012 Samuel Tebege
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 haganirregularswaptionengine.hpp
22 \brief engine for pricing irregular swaptions via super-replication
23*/
24
25#ifndef quantlib_hagan_irregular_swaption_engine_hpp
26#define quantlib_hagan_irregular_swaption_engine_hpp
27
33
34namespace QuantLib {
35
36 //! Pricing engine for irregular swaptions
37 /*! References:
38
39 1. P.S. Hagan: "Methodology for Callable Swaps and Bermudan
40 'Exercise into Swaptions'"
41 2. P.J. Hunt, J.E. Kennedy: "Implied interest rate pricing
42 models", Finance Stochast. 2, 275-293 (1998)
43
44 \warning Currently a spread is not handled correctly; it
45 should be a minor exercise to account for this
46 feature as well;
47 */
49 : public GenericEngine<IrregularSwaption::arguments,
50 IrregularSwaption::results> {
51 public:
52 //@{
56 //@}
57 void calculate() const override;
58
59 // helper class
60 class Basket {
61 public:
62 Basket(ext::shared_ptr<IrregularSwap> swap,
63 Handle<YieldTermStructure> termStructure,
64 Handle<SwaptionVolatilityStructure> volatilityStructure);
65 Array compute(Rate lambda = 0.0) const;
66 Real operator()(Rate x) const;
67 ext::shared_ptr<VanillaSwap> component(Size i) const;
68 Array weights() const { return compute(lambda_); };
69 Real& lambda() const { return lambda_; };
70 // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
71 ext::shared_ptr<IrregularSwap> swap() const { return swap_; };
72 private:
73 ext::shared_ptr<IrregularSwap> swap_;
76
78
79 ext::shared_ptr<PricingEngine> engine_;
80
81 std::vector<Real> fairRates_;
82 std::vector<Real> annuities_;
83 std::vector<Date> expiries_;
84
85 mutable Real lambda_ = 0.0;
86 };
87
88 Real HKPrice(Basket& basket,ext::shared_ptr<Exercise>& exercise) const;
89 Real LGMPrice(Basket& basket,ext::shared_ptr<Exercise>& exercise) const;
90
91 private:
94 class rStarFinder;
95 };
96
97}
98
99#endif
1-D array used in linear algebra.
Definition: array.hpp:52
template base class for option pricing engines
Handle< SwaptionVolatilityStructure > volatilityStructure_
ext::shared_ptr< VanillaSwap > component(Size i) const
Pricing engine for irregular swaptions.
Real LGMPrice(Basket &basket, ext::shared_ptr< Exercise > &exercise) const
Real HKPrice(Basket &basket, ext::shared_ptr< Exercise > &exercise) const
Handle< SwaptionVolatilityStructure > volatilityStructure_
Shared handle to an observable.
Definition: handle.hpp:41
Optimization cost function class.
QL_REAL Real
real number
Definition: types.hpp:50
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Irregular swaption class.
Helper class to instantiate standard market swaps.
Definition: any.hpp:35
Swaption volatility structure.
Interest-rate term structure.