Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
jyyoyinflationcouponpricer.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 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
22
23using QuantLib::Option;
24using QuantLib::Rate;
25using QuantLib::Real;
26using QuantLib::Size;
27
28namespace QuantExt {
29
30JyYoYInflationCouponPricer::JyYoYInflationCouponPricer(const QuantLib::ext::shared_ptr<CrossAssetModel>& model, Size index)
31 : YoYInflationCouponPricer(model->irlgm1f(model->ccyIndex(model->infjy(index)->currency()))->termStructure()),
32 model_(model), index_(index) {
33
34 Size irIdx = model_->ccyIndex(model_->infjy(index_)->currency());
35 nominalTermStructure_ = model_->irlgm1f(irIdx)->termStructure();
36
37 registerWith(model_);
38 registerWith(nominalTermStructure_);
39}
40
41Real JyYoYInflationCouponPricer::optionletRate(Option::Type optionType, Real effStrike) const {
42 QL_FAIL("JyYoYInflationCouponPricer::optionletRate: not implemented.");
43}
44
46
47 // We only need to use the Jarrow Yildrim model if both I(T) and I(S) are not yet known (i.e. published).
48 // If only I(S) is known, we have a ZCIIS. If both are known, we just use the published values. In either case,
49 // we can just ask the inflation index for its fixing.
50
51 // Fixing date associated with numerator inflation index value i.e. I(T). Incorporates the observation lag.
52 // It is essentially: coupon_end_date - contract_observation_lag.
53 Date numFixingDate = coupon_->fixingDate();
54
55 // Fixing date associated with denominator inflation index value i.e. I(S).
56 Date denFixingDate = numFixingDate - 1 * Years;
57
58 // If everything has been published in order to determine I(S), return model independent value read off curve.
59 // Logic to determine last available fixing and where forecasting is needed copied from YoYInflationIndex::fixing.
60 Date today = Settings::instance().evaluationDate();
61 const auto& index = coupon_->yoyIndex();
62 auto freq = index->frequency();
63 auto ip = inflationPeriod(today - index->availabilityLag(), freq);
64 bool isInterp = index->interpolated();
65 if ((!isInterp && denFixingDate < ip.first) || (isInterp && denFixingDate < ip.first - Period(freq))) {
66 return coupon_->indexFixing();
67 }
68
69 // Use the JY model to calculate the adjusted fixing.
70 auto zts = model_->infjy(index_)->realRate()->termStructure();
71 auto S = inflationTime(denFixingDate, *zts, index->interpolated());
72 auto T = inflationTime(numFixingDate, *zts, index->interpolated());
73
74 return jyExpectedIndexRatio(model_, index_, S, T, index->interpolated()) - 1;
75}
76
77Real jyExpectedIndexRatio(const QuantLib::ext::shared_ptr<CrossAssetModel>& model, Size index, Time S, Time T,
78 bool indexIsInterpolated) {
79
80 using namespace CrossAssetAnalytics;
81 auto irIdx = model->ccyIndex(model->infjy(index)->currency());
82 auto irTs = model->irlgm1f(irIdx)->termStructure();
83 auto zts = model->infjy(index)->realRate()->termStructure();
84
85 // Calculate growthRatio: \frac{P_r(0,T)}{P_n(0,T)} / \frac{P_r(0,S)}{P_n(0,S)}
86 auto growthRatio = inflationGrowth(zts, T, indexIsInterpolated) / inflationGrowth(zts, S, indexIsInterpolated);
87
88 // Calculate exponent of the convexity adjustment i.e. c.
89 auto rrParam = model->infjy(index)->realRate();
90 auto H_r_S = rrParam->H(S);
91 auto H_r_T = rrParam->H(T);
92 auto H_n_S = model->irlgm1f(irIdx)->H(S);
93
94 auto c = H_r_S * rrParam->zeta(S);
95 c -= H_n_S * integral(*model, P(rzy(irIdx, index, 0), az(irIdx), ay(index)), 0.0, S);
96 c += integral(*model,
97 LC(0.0, -1.0, P(ay(index), ay(index), Hy(index)), 1.0,
98 P(rzy(irIdx, index, 0), az(irIdx), ay(index), Hz(irIdx)), -1.0,
99 P(ryy(index, index, 0, 1), ay(index), sy(index))),
100 0.0, S);
101 c *= (H_r_S - H_r_T);
102
103 return growthRatio * exp(c);
104}
105
106} // namespace QuantExt
JyYoYInflationCouponPricer(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, QuantLib::Size index)
QuantLib::ext::shared_ptr< CrossAssetModel > model_
QuantLib::Rate adjustedFixing(QuantLib::Rate fixing=QuantLib::Null< QuantLib::Rate >()) const override
QuantLib::Real optionletRate(QuantLib::Option::Type optionType, QuantLib::Real effStrike) const override
analytics for the cross asset model
const LC1_< E1 > LC(QuantLib::Real c, QuantLib::Real c1, const E1 &e1)
Real integral(const CrossAssetModel &model, const E &e, const Real a, const Real b)
const P2_< E1, E2 > P(const E1 &e1, const E2 &e2)
some inflation related utilities.
Jarrow Yildrim (JY) pricer for capped or floored year on year (YoY) inflation coupons.
Real jyExpectedIndexRatio(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index, Time S, Time T, bool indexIsInterpolated)
CompiledFormula exp(CompiledFormula x)
Time inflationTime(const Date &date, const QuantLib::ext::shared_ptr< InflationTermStructure > &inflationTs, bool indexIsInterpolated, const DayCounter &dayCounter)
Definition: inflation.cpp:61
Real inflationGrowth(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, Size index, Time S, Time T, Real irState, Real rrState, bool indexIsInterpolated)
INF H component. May relate to real rate portion of JY model or z component of DK model.
INF alpha component. May relate to real rate portion of JY model or z component of DK model.
JY INF index sigma component.