Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
lognormalcmsspreadpricer.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/*
20 Copyright (C) 2014, 2015, 2018 Peter Caspers
21
22 This file is part of QuantLib, a free-software/open-source library
23 for financial quantitative analysts and developers - http://quantlib.org/
24
25 QuantLib is free software: you can redistribute it and/or modify it
26 under the terms of the QuantLib license. You should have received a
27 copy of the license along with this program; if not, please email
28 <quantlib-dev@lists.sf.net>. The license is also available online at
29 <http://quantlib.org/license.shtml>.
30
31
32 This program is distributed in the hope that it will be useful, but
33 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
34 or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */
35
36/*! \file lognormalcmsspreadpricer.hpp
37 \brief cms spread coupon pricer as in Brigo, Mercurio, 13.6.2, with
38 extensions for shifted lognormal and normal dynamics as
39 described in http://ssrn.com/abstract=2686998
40*/
41
42#ifndef quantext_lognormal_cmsspread_pricer_hpp
43#define quantext_lognormal_cmsspread_pricer_hpp
44
45#include <ql/cashflows/cmscoupon.hpp>
46#include <ql/experimental/coupons/cmsspreadcoupon.hpp>
47#include <ql/experimental/coupons/swapspreadindex.hpp>
48#include <ql/math/distributions/normaldistribution.hpp>
49#include <ql/math/integrals/gaussianquadratures.hpp>
50
53
54namespace QuantLib {
55class CmsSpreadCoupon;
56class YieldTermStructure;
57} // namespace QuantLib
58
59namespace QuantExt {
60using namespace QuantLib;
61
62//! base pricer for vanilla CMS spread coupons with a correlation surface
64public:
66 const Handle<CorrelationTermStructure>& correlation = Handle<CorrelationTermStructure>())
67 : CmsSpreadCouponPricer(Handle<Quote>(QuantLib::ext::make_shared<ExceptionQuote>(
68 "CmsSpreadPricer2 doesn't support 'correlation()', instead use 'correlation(Time, Strike)'"))),
70 registerWith(correlationCurve_);
71 }
72
73 Real correlation(Time t, Real strike = 1) const { return correlationCurve_->correlation(t, strike); }
74
75 void setCorrelationCurve(const Handle<CorrelationTermStructure>& correlation = Handle<CorrelationTermStructure>()) {
76 unregisterWith(correlationCurve_);
78 registerWith(correlationCurve_);
79 update();
80 }
81
82private:
83 Handle<CorrelationTermStructure> correlationCurve_;
84};
85
86//! CMS spread - coupon pricer
87/*! The swap rate adjustments are computed using the given
88 volatility structures for the underlyings in every case
89 (w.r.t. volatility type and shift).
90
91 For the bivariate spread model, the volatility type and
92 the shifts can be inherited (default), or explicitly
93 specified. In the latter case the type, and (if lognormal)
94 the shifts must be given (or are defaulted to zero, if not
95 given).
96
97 References:
98
99 Brigo, Mercurio: Interest Rate Models - Theory and Practice,
100 2nd Edition, Springer, 2006, chapter 13.6.2
101
102 http://ssrn.com/abstract=2686998
103*/
104
106
107public:
108 LognormalCmsSpreadPricer(const QuantLib::ext::shared_ptr<CmsCouponPricer> cmsPricer,
109 const Handle<QuantExt::CorrelationTermStructure>& correlation,
110 const Handle<YieldTermStructure>& couponDiscountCurve = Handle<YieldTermStructure>(),
111 const Size IntegrationPoints = 16,
112 const boost::optional<VolatilityType> volatilityType = boost::none,
113 const Real shift1 = Null<Real>(), const Real shift2 = Null<Real>());
114
115 /* */
116 virtual Real swapletPrice() const override;
117 virtual Rate swapletRate() const override;
118 virtual Real capletPrice(Rate effectiveCap) const override;
119 virtual Rate capletRate(Rate effectiveCap) const override;
120 virtual Real floorletPrice(Rate effectiveFloor) const override;
121 virtual Rate floorletRate(Rate effectiveFloor) const override;
122
123private:
124 void initialize(const FloatingRateCoupon& coupon) override;
125 Real rho() const { return std::max(std::min(correlation(fixingTime_), 0.9999), -0.9999); }
126 Real optionletPrice(Option::Type optionType, Real strike) const;
127
128 Real integrand(const Real) const;
129 Real integrand_normal(const Real) const;
130
131 class integrand_f;
132 friend class integrand_f;
133
134 QuantLib::ext::shared_ptr<CmsCouponPricer> cmsPricer_;
135
136 Handle<YieldTermStructure> couponDiscountCurve_;
137
138 const CmsSpreadCoupon* coupon_;
139
141
143
147
148 QuantLib::ext::shared_ptr<SwapSpreadIndex> index_;
149
150 QuantLib::ext::shared_ptr<CumulativeNormalDistribution> cnd_;
151 QuantLib::ext::shared_ptr<GaussianQuadrature> integrator_;
152
156 Real mu1_, mu2_;
157
159 VolatilityType volType_;
161
162 mutable Real phi_, a_, b_, s1_, s2_, m1_, m2_, v1_, v2_, k_;
163 mutable Real alpha_, psi_;
164 mutable Option::Type optionType_;
165
166 QuantLib::ext::shared_ptr<CmsCoupon> c1_, c2_;
167};
168
169} // namespace QuantExt
170
171#endif
base pricer for vanilla CMS spread coupons with a correlation surface
CmsSpreadCouponPricer2(const Handle< CorrelationTermStructure > &correlation=Handle< CorrelationTermStructure >())
Real correlation(Time t, Real strike=1) const
Handle< CorrelationTermStructure > correlationCurve_
void setCorrelationCurve(const Handle< CorrelationTermStructure > &correlation=Handle< CorrelationTermStructure >())
A dummy quote class that throws an exception when value is called.
virtual Real capletPrice(Rate effectiveCap) const override
virtual Rate floorletRate(Rate effectiveFloor) const override
QuantLib::ext::shared_ptr< CmsCoupon > c1_
void initialize(const FloatingRateCoupon &coupon) override
QuantLib::ext::shared_ptr< GaussianQuadrature > integrator_
QuantLib::ext::shared_ptr< CmsCoupon > c2_
QuantLib::ext::shared_ptr< CmsCouponPricer > cmsPricer_
QuantLib::ext::shared_ptr< SwapSpreadIndex > index_
QuantLib::ext::shared_ptr< CumulativeNormalDistribution > cnd_
Handle< YieldTermStructure > couponDiscountCurve_
virtual Rate swapletRate() const override
virtual Real floorletPrice(Rate effectiveFloor) const override
virtual Real swapletPrice() const override
Real optionletPrice(Option::Type optionType, Real strike) const
virtual Rate capletRate(Rate effectiveCap) const override
Term structure of correlations.
throws exception when called