Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
analyticlgmswaptionengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file pricingengines/analyticlgmswaptionengine.hpp
20 \brief analytic engine for european swaptions in the LGM model
21
22 \ingroup engines
23*/
24
25#ifndef quantext_analytic_lgm_swaption_engine_hpp
26#define quantext_analytic_lgm_swaption_engine_hpp
27
28#include <ql/instruments/swaption.hpp>
29#include <ql/cashflows/floatingratecoupon.hpp>
30#include <ql/cashflows/fixedratecoupon.hpp>
32
33namespace QuantExt {
34
35//! Analytic LGM swaption engine for european exercise
36/*! \ingroup swaptionengines
37
38 All fixed coupons with start date greater or equal to the respective
39 option expiry are considered to be
40 part of the exercise into right.
41
42 References:
43
44 Hagan, Evaluating and hedging exotic swap instruments via LGM
45
46 Lichters, Stamm, Gallagher: Modern Derivatives Pricing and Credit Exposure
47 Analysis, Palgrave Macmillan, 2015, 11.2.2
48
49 \warning Cash settled swaptions are not supported
50
51 The basis between the given discounting curve (or - if not given - the
52 model curve) and the forwarding curve attached to the underlying swap's
53 ibor index is taken into account by a static correction spread for
54 the underlying's fixed leg. Likewise a spread on the floating leg is
55 taken into account.
56
57 Note that we assume H' does not change its sign, but this is a general
58 requirement of the LGM parametrization anyway (see the base parametrization
59 class).
60
61 \ingroup engines
62*/
63
64class AnalyticLgmSwaptionEngine : public GenericEngine<Swaption::arguments, Swaption::results> {
65
66public:
67 /*! nextCoupon is Mapping A, proRata is Mapping B
68 in Lichters, Stamm, Gallagher (2015), 11.2.2 */
70
71 /*! Lgm model based constructor */
72 AnalyticLgmSwaptionEngine(const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model,
73 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
74 const FloatSpreadMapping floatSpreadMapping = proRata);
75
76 /*! CrossAsset model based constructor */
77 AnalyticLgmSwaptionEngine(const QuantLib::ext::shared_ptr<CrossAssetModel>& model, const Size ccy,
78 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
79 const FloatSpreadMapping floatSpreadMapping = proRata);
80
81 /*! parametrization based constructor, note that updates in the
82 parametrization are not observed by the engine, you would
83 have to call update() on the engine explicitly */
84 AnalyticLgmSwaptionEngine(const QuantLib::ext::shared_ptr<IrLgm1fParametrization> irlgm1f,
85 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
86 const FloatSpreadMapping floatSpreadMapping = proRata);
87
88 void calculate() const override;
89
90 /* If enabled, the underlying instrument should not changed between two pricings or the cache has to be
91 cleared. Furthermore it is assumed that all the market data stays constant between two pricings.
92 Regarding the LGM parameters it is assumed that either H(t) or alpha(t) (or both) is constant, depending
93 on the passed parameters here. enableCache() should only be called once on an instance of this class. */
94 void enableCache(const bool lgm_H_constant = true, const bool lgm_alpha_constant = false);
95 void clearCache();
96
97private:
98 Real flatAmount(const Size k) const;
99 Real yStarHelper(const Real y) const;
100 QuantLib::ext::shared_ptr<IrLgm1fParametrization> p_;
101 Handle<YieldTermStructure> c_;
104 mutable Real H0_, D0_, zetaex_, S_m1, u_, w_;
105 mutable std::vector<Real> S_, Hj_, Dj_;
106 mutable Size j1_, k1_;
107 mutable std::vector<QuantLib::ext::shared_ptr<FixedRateCoupon>> fixedLeg_;
108 mutable std::vector<QuantLib::ext::shared_ptr<FloatingRateCoupon>> floatingLeg_;
109 mutable Real nominal_;
110};
111
112} // namespace QuantExt
113
114#endif
Analytic LGM swaption engine for european exercise.
QuantLib::ext::shared_ptr< IrLgm1fParametrization > p_
std::vector< QuantLib::ext::shared_ptr< FixedRateCoupon > > fixedLeg_
void enableCache(const bool lgm_H_constant=true, const bool lgm_alpha_constant=false)
std::vector< QuantLib::ext::shared_ptr< FloatingRateCoupon > > floatingLeg_
cross asset model