Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
discountingcurrencyswapenginedeltagamma.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 qle/pricingengines/discountingcurrencyswapenginedeltagamma.hpp
20 \brief discounting currency swap engine providing analytical deltas
21 and gammas for vanilla swaps
22
23 \ingroup engines
24*/
25
26#ifndef quantext_discounting_currencyswap_engine_delta_hpp
27#define quantext_discounting_currencyswap_engine_delta_hpp
28
29#include <ql/currency.hpp>
30#include <ql/handle.hpp>
31#include <ql/math/matrix.hpp>
32#include <ql/termstructures/yieldtermstructure.hpp>
33
36
37namespace QuantExt {
38
39//! Discounting currency swap engine providing analytical deltas and gammas
40/*! This class generalizes QuantLib's DiscountingSwapEngine. It takes leg currencies into account and converts into the
41 provided "npv currency", which must be one of the leg currencies. The evaluation date is the reference date of either
42 of the discounting curves (which must be equal).
43
44 The same comments as in discountingswapenginedeltagamma.hpp apply here, so read them first.
45
46 The engine processes FX linked flows from xccy resetting swaps, but only captures the additional FX Spot Delta risk
47 coming from the reset feature. Interest Deltas and Gammas coming from the FX forwarding factor P_for / P_dom are
48 neglected, this factor is treated as a constant for the purpose of sensitivity calculation.
49
50 Here, the additional results are:
51
52 deltaDiscount (map<Currency, vector<Real>> ): Delta on discount curve, rebucketed, values are in currency
53 deltaForward (map<Currency, vector<Real>> ): Delta on forward curve, rebucketed, value are in currency
54 deltaFxSpot (map<Currency, Real> ): Delta on FX Spot (for all leg currencies, even if = npv ccy)
55
56 gamma (map<Currency, Matrix> ): Gamma matrix per currency with blocks | dsc-dsc dsc-fwd |
57 | dsc-fwd fwd-fwd |
58 (note that the second derivatives including the FX Spot are zero for the pure second derivative w.r.t. the FX Spot or
59 given by the in currency delta values provided as the additional result deltaDiscount, deltaForward, to be
60 reinterpreted as values in domestic currency)
61
62 fxSpot (map<Currency, Real> ): FX Spot used for conversion to npvCurrency (for all leg ccys)
63 bucketTimes (vector<Real> ): Bucketing grid for deltas and gammas
64
65 \warning: The assumption is that per currency we only have one discount and one forward curve. It is possible to have
66 several, but then the computed deltas will be aggregated over all those curves.
67*/
68
70public:
71 typedef std::map<Currency, Matrix, CurrencyComparator> result_type_matrix;
72 typedef std::map<Currency, std::vector<Real>, CurrencyComparator> result_type_vector;
73 typedef std::map<Currency, Real, CurrencyComparator> result_type_scalar;
74
75 /*! The FX spots must be given as units of npvCurrency per respective currency. The spots must be given w.r.t. a
76 settlement date equal to the npv date (which is the reference date of the term structures).
77
78 If applySimmExemptions = true, simple cashflows will be excluded from the additional
79 results listed above (but not from the npv / leg npv results) if
80 - the underlying instrument is physically settled and
81 - the underlying instrument is not a resettable swap
82 Notice that the SIMM adjustments for resettable swaps are _not_ applied though!
83 */
84 DiscountingCurrencySwapEngineDeltaGamma(const std::vector<Handle<YieldTermStructure>>& discountCurves,
85 const std::vector<Handle<Quote>>& fxQuotes,
86 const std::vector<Currency>& currencies, const Currency& npvCurrency,
87 const std::vector<Time>& bucketTimes = std::vector<Time>(),
88 const bool computeDelta = false, const bool computeGamma = false,
89 const bool linearInZero = true, const bool applySimmExemptions = false);
90 void calculate() const override;
91 std::vector<Handle<YieldTermStructure>> discountCurves() { return discountCurves_; }
92 std::vector<Currency> currencies() { return currencies_; }
93 Currency npvCurrency() { return npvCurrency_; }
94
95private:
96 Handle<YieldTermStructure> fetchTS(Currency ccy) const;
97 Handle<Quote> fetchFX(Currency ccy) const;
98
99 const std::vector<Handle<YieldTermStructure>> discountCurves_;
100 const std::vector<Handle<Quote>> fxQuotes_;
101 const std::vector<Currency> currencies_;
102 const Currency npvCurrency_;
103 const std::vector<Time> bucketTimes_;
105};
106} // namespace QuantExt
107
108#endif
Discounting currency swap engine providing analytical deltas and gammas.
const std::vector< Handle< YieldTermStructure > > discountCurves_
std::map< Currency, std::vector< Real >, CurrencyComparator > result_type_vector
std::map< Currency, Real, CurrencyComparator > result_type_scalar
std::map< Currency, Matrix, CurrencyComparator > result_type_matrix
Compare currencies by currency code.
Interest rate swap with extended interface.