/
lognormalcmsspreadpricer.hpp
125 lines (91 loc) · 4.18 KB
/
lognormalcmsspreadpricer.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2014, 2015, 2018 Peter Caspers
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */
/*! \file lognormalcmsspreadpricer.hpp
\brief cms spread coupon pricer as in Brigo, Mercurio, 13.6.2, with
extensions for shifted lognormal and normal dynamics as
described in http://ssrn.com/abstract=2686998
*/
#ifndef quantlib_lognormal_cmsspread_pricer_hpp
#define quantlib_lognormal_cmsspread_pricer_hpp
#include <ql/cashflows/cmscoupon.hpp>
#include <ql/experimental/coupons/cmsspreadcoupon.hpp>
#include <ql/experimental/coupons/swapspreadindex.hpp>
#include <ql/math/integrals/gaussianquadratures.hpp>
#include <ql/math/distributions/normaldistribution.hpp>
namespace QuantLib {
class CmsSpreadCoupon;
class YieldTermStructure;
//! CMS spread - coupon pricer
/*! The swap rate adjustments are computed using the given
volatility structures for the underlyings in every case
(w.r.t. volatility type and shift).
For the bivariate spread model, the volatility type and
the shifts can be inherited (default), or explicitly
specified. In the latter case the type, and (if lognormal)
the shifts must be given (or are defaulted to zero, if not
given).
References:
Brigo, Mercurio: Interst Rate Models - Theory and Practice,
2nd Edition, Springer, 2006, chapter 13.6.2
http://ssrn.com/abstract=2686998
*/
class LognormalCmsSpreadPricer : public CmsSpreadCouponPricer {
public:
LognormalCmsSpreadPricer(
const ext::shared_ptr<CmsCouponPricer>& cmsPricer,
const Handle<Quote>& correlation,
Handle<YieldTermStructure> couponDiscountCurve = Handle<YieldTermStructure>(),
Size IntegrationPoints = 16,
const boost::optional<VolatilityType>& volatilityType = boost::none,
Real shift1 = Null<Real>(),
Real shift2 = Null<Real>());
/* */
Real swapletPrice() const override;
Rate swapletRate() const override;
Real capletPrice(Rate effectiveCap) const override;
Rate capletRate(Rate effectiveCap) const override;
Real floorletPrice(Rate effectiveFloor) const override;
Rate floorletRate(Rate effectiveFloor) const override;
private:
void initialize(const FloatingRateCoupon& coupon) override;
Real optionletPrice(Option::Type optionType, Real strike) const;
Real integrand(Real) const;
Real integrand_normal(Real) const;
class integrand_f;
ext::shared_ptr<CmsCouponPricer> cmsPricer_;
Handle<YieldTermStructure> couponDiscountCurve_;
const CmsSpreadCoupon *coupon_;
Date today_, fixingDate_, paymentDate_;
Real fixingTime_;
Real gearing_, spread_;
Real spreadLegValue_;
Real discount_;
ext::shared_ptr<SwapSpreadIndex> index_;
ext::shared_ptr<CumulativeNormalDistribution> cnd_;
ext::shared_ptr<GaussianQuadrature> integrator_;
Real swapRate1_, swapRate2_, gearing1_, gearing2_;
Real adjustedRate1_, adjustedRate2_;
Real vol1_, vol2_;
Real mu1_, mu2_;
Real rho_;
bool inheritedVolatilityType_;
VolatilityType volType_;
Real shift1_, shift2_;
mutable Real phi_, a_, b_, s1_, s2_, m1_, m2_, v1_, v2_, k_;
mutable Real alpha_, psi_;
mutable Option::Type optionType_;
ext::shared_ptr<CmsCoupon> c1_, c2_;
};
}
#endif