QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
quantocouponpricer.cpp
Go to the documentation of this file.
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
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);
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
Black formula.
Floating rate coupon with additional cap/floor.
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
Rate indexFixing() const override
fixing of the underlying index
Definition: iborcoupon.cpp:91
Date fixingDate() const override
fixing date
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
Cms-rate coupon with digital call/put option.
Floating-rate coupon with digital call/put option.
Ibor-rate coupon with digital call/put option.
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
Real rho
Real sigma
base class for interest rate indexes
Definition: any.hpp:35
quanto-adjusted coupon
range-accrual coupon