QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
haganirregularswaptionengine.hpp
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
25#ifndef quantlib_hagan_irregular_swaption_engine_hpp
26#define quantlib_hagan_irregular_swaption_engine_hpp
27
28#include <ql/experimental/swaptions/irregularswaption.hpp>
29#include <ql/termstructures/yieldtermstructure.hpp>
30#include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
31#include <ql/math/optimization/costfunction.hpp>
32#include <ql/instruments/makevanillaswap.hpp>
33
34namespace QuantLib {
35
37
49 : public GenericEngine<IrregularSwaption::arguments,
50 IrregularSwaption::results> {
51 public:
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
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
Definition: any.hpp:35