Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
numericlgmflexiswapengine.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2018 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 qle/pricingengines/numericlgmflexiswapengine.hpp
20 \brief numeric engine for flexi swaps in the LGM model
21*/
22
23#pragma once
24
26
27#include <qle/models/lgm.hpp>
30
31#include <ql/indexes/iborindex.hpp>
32#include <ql/math/distributions/normaldistribution.hpp>
33#include <ql/pricingengines/genericmodelengine.hpp>
34
35namespace QuantExt {
36
37//! Numerical engine for flexi swaps in the LGM model
38/*! This is a modifed version of qle/pricingengines/numericlgmswaptionengine.hpp
39 Reference: F. Jamshidian, Replication of Flexi-swaps, January 2005
40
41 There are two implementations of the rollback
42
43 a) SingleSwaptions: price each swaption on its own, using the grid rollback
44 b) SwaptionArray: price all swaptions simultaneously by rolling back suitable
45 Arrays instead of Reals
46
47 For a large swaption basket b) is faster than a). The two methods can be specified
48 explicitly or the Automatic mode can be used which uses a) if the "effective number
49 of full swaptions" is below the given singleSwaptionThreshold and b) otherwise.
50
51 Here, the effective number of full swaptions is defined to be the sum of event dates
52 of all the swaptions in the basket divided by the number of event dates of the full
53 underlying.
54*/
55
57public:
59 NumericLgmFlexiSwapEngineBase(const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model, const Real sy, const Size ny,
60 const Real sx, const Size nx,
61 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
62 const Method method = Method::Automatic, const Real singleSwaptionThreshold = 20.0);
63
64protected:
65 // returns option value, underlying value
66 std::pair<Real, Real> calculate() const;
67 // helper method, compute underlying value w.r.t. an assumed unit notional
68 Real underlyingValue(const Real, const Real, const Date&, const Size, const Size, const Real, const Real) const;
69 // parameters
70 const Handle<YieldTermStructure> discountCurve_;
73 //
74 mutable QuantLib::ext::shared_ptr<IborIndex> iborModelIndex_;
75 mutable QuantLib::ext::shared_ptr<LgmImpliedYieldTermStructure> iborModelCurve_;
76 // arguments to be set by derived pricing engines before calling calculate()
77 mutable VanillaSwap::Type type;
78 mutable std::vector<Real> fixedNominal, floatingNominal;
79 mutable std::vector<Date> fixedResetDates;
80 mutable std::vector<Date> fixedPayDates;
81 mutable std::vector<Time> floatingAccrualTimes;
82 mutable std::vector<Date> floatingResetDates;
83 mutable std::vector<Date> floatingFixingDates;
84 mutable std::vector<Date> floatingPayDates;
85 mutable std::vector<Real> fixedCoupons;
86 mutable std::vector<Real> fixedRate;
87 mutable std::vector<Real> floatingGearings;
88 mutable std::vector<Real> floatingSpreads;
89 mutable std::vector<Real> cappedRate;
90 mutable std::vector<Real> flooredRate;
91 mutable std::vector<Real> floatingCoupons;
92 mutable QuantLib::ext::shared_ptr<IborIndex> iborIndex;
93 mutable std::vector<Real> lowerNotionalBound;
94 mutable QuantLib::Position::Type optionPosition;
95 mutable std::vector<bool> notionalCanBeDecreased;
96}; // NumericLgmFlexiSwapEngineBase
97
98class NumericLgmFlexiSwapEngine : public GenericEngine<FlexiSwap::arguments, FlexiSwap::results>,
100public:
101 NumericLgmFlexiSwapEngine(const QuantLib::ext::shared_ptr<LinearGaussMarkovModel>& model, const Real sy, const Size ny,
102 const Real sx, const Size nx,
103 const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>(),
104 const Method method = Method::Automatic, const Real singleSwaptionThreshold = 20.0);
105
106private:
107 void calculate() const override;
108}; // NnumercLgmFlexiSwapEngine
109
110} // namespace QuantExt
Numerical convolution solver for the LGM model.
const QuantLib::ext::shared_ptr< LinearGaussMarkovModel > & model() const
Numerical engine for flexi swaps in the LGM model.
const Handle< YieldTermStructure > discountCurve_
QuantLib::ext::shared_ptr< IborIndex > iborIndex
QuantLib::ext::shared_ptr< LgmImpliedYieldTermStructure > iborModelCurve_
QuantLib::ext::shared_ptr< IborIndex > iborModelIndex_
Real underlyingValue(const Real, const Real, const Date &, const Size, const Size, const Real, const Real) const
Flexi-Swap instrument with global notional bounds.
lgm model class
numeric convolution solver for the LGM model
yield term structure implied by a LGM model
JY INF index sigma component.