QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
quantocouponpricer.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Toyin Akin
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/experimental/coupons/quantocouponpricer.hpp>
21#include <ql/cashflows/capflooredcoupon.hpp>
22#include <ql/cashflows/digitalcoupon.hpp>
23#include <ql/cashflows/digitalcmscoupon.hpp>
24#include <ql/cashflows/digitaliborcoupon.hpp>
25#include <ql/cashflows/rangeaccrual.hpp>
26#include <ql/pricingengines/blackformula.hpp>
27#include <ql/indexes/interestrateindex.hpp>
28
29namespace QuantLib {
30
32
33 if (fixing == Null<Rate>())
34 fixing = coupon_->indexFixing();
35
36 // Here we apply the quanto adjustment first, then delegate to
37 // the parent class
38 Date d1 = coupon_->fixingDate(),
39 referenceDate = capletVolatility()->referenceDate();
40
41 if (d1 > referenceDate) {
42 Time t1 =
43 capletVolatility()->timeFromReference(d1);
44 Volatility fxsigma =
45 fxRateBlackVolatility_->blackVol(d1, fixing, true);
46 Volatility sigma = capletVolatility()->volatility(d1, fixing);
47 Real rho = underlyingFxCorrelation_->value();
48
49 // Apply Quanto Adjustment.
50 // Hull 6th Edition, page 642, generalised to
51 // shifted lognormal and normal volatilities
52 if(capletVolatility()->volatilityType() == ShiftedLognormal) {
53 Real dQuantoAdj = std::exp(sigma*fxsigma*rho*t1);
54 Real shift = capletVolatility()->displacement();
55 fixing = (fixing+shift)*dQuantoAdj-shift;
56 }
57 else {
58 Real dQuantoAdj = sigma*fxsigma*rho*t1;
59 fixing += dQuantoAdj;
60 }
61 }
62
64 }
65
66}
67
virtual Rate adjustedFixing(Rate fixing=Null< Rate >()) const
Rate adjustedFixing(Rate fixing=Null< Rate >()) const override
Handle< BlackVolTermStructure > fxRateBlackVolatility_
Concrete date class.
Definition: date.hpp:125
virtual Date fixingDate() const
fixing date
Rate indexFixing() const override
fixing of the underlying index
Definition: iborcoupon.cpp:87
Handle< OptionletVolatilityStructure > capletVolatility() const
const IborCoupon * coupon_
template class providing a null value for a given type.
Definition: null.hpp:76
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35