Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
quantocouponpricer.cpp
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) 2008 Toyin Akin
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 This program is distributed in the hope that it will be useful, but WITHOUT
32 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
33 FOR A PARTICULAR PURPOSE. See the license for more details.
34*/
35
37
38#include <ql/cashflows/capflooredcoupon.hpp>
39#include <ql/cashflows/digitalcmscoupon.hpp>
40#include <ql/cashflows/digitalcoupon.hpp>
41#include <ql/cashflows/digitaliborcoupon.hpp>
42#include <ql/cashflows/rangeaccrual.hpp>
43#include <ql/indexes/interestrateindex.hpp>
44#include <ql/pricingengines/blackformula.hpp>
45
46using namespace QuantLib;
47
48namespace QuantExt {
49
51
52 if (fixing == Null<Rate>())
53 fixing = coupon_->indexFixing();
54
55 // Here we apply the quanto adjustment first, then delegate to
56 // the parent class
57 Date d1 = coupon_->fixingDate(), referenceDate = capletVolatility()->referenceDate();
58
59 if (d1 > referenceDate) {
60 Time t1 = capletVolatility()->timeFromReference(d1);
61 Volatility fxsigma = fxRateBlackVolatility_->blackVol(d1, fixing, true);
62 Volatility sigma = capletVolatility()->volatility(d1, fixing);
63 Real rho = underlyingFxCorrelation_->value();
64
65 // Apply Quanto Adjustment.
66 // Hull 6th Edition, page 642, generalised to
67 // shifted lognormal and normal volatilities
68 if (capletVolatility()->volatilityType() == ShiftedLognormal) {
69 Real dQuantoAdj = std::exp(sigma * fxsigma * rho * t1);
70 Real shift = capletVolatility()->displacement();
71 fixing = (fixing + shift) * dQuantoAdj - shift;
72 } else {
73 Real dQuantoAdj = sigma * fxsigma * rho * t1;
74 fixing += dQuantoAdj;
75 }
76 }
77
78 return BlackIborCouponPricer::adjustedFixing(fixing);
79}
80
81} // namespace QuantExt
Handle< QuantLib::BlackVolTermStructure > fxRateBlackVolatility_
Rate adjustedFixing(Rate fixing=Null< Rate >()) const override
Handle< QuantLib::Quote > underlyingFxCorrelation_
quanto-adjusted coupon