Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
analyticdkcpicapfloorengine.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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
21
22#include <ql/pricingengines/blackformula.hpp>
23
24namespace QuantExt {
25
26using namespace CrossAssetAnalytics;
27
28AnalyticDkCpiCapFloorEngine::AnalyticDkCpiCapFloorEngine(const QuantLib::ext::shared_ptr<CrossAssetModel>& model,
29 const Size index, const Real baseCPI)
30 : model_(model), index_(index), baseCPI_(baseCPI) {}
31
33
34 QL_DEPRECATED_DISABLE_WARNING
35 bool interpolate = arguments_.observationInterpolation == CPI::Linear ||
36 (arguments_.observationInterpolation == CPI::AsIndex && arguments_.index->interpolated());
37 QL_DEPRECATED_ENABLE_WARNING
38
39 Real t = inflationYearFraction(arguments_.index->frequency(), interpolate,
40 model_->infdk(index_)->termStructure()->dayCounter(),
41 model_->infdk(index_)->termStructure()->baseDate(), arguments_.fixDate);
42
43 if (t <= 0.0) {
44 // option is expired, we do not value any possibly non settled
45 // flows, i.e. set the npv to zero in this case
46 results_.value = 0.0;
47 return;
48 }
49
50 // Book, 13.37, 13.38
51
52 Real k = std::pow(1.0 + arguments_.strike, t);
53 Real kTilde = k * arguments_.baseCPI;
54 Real nTilde = arguments_.nominal / arguments_.baseCPI;
55
56 Real m = baseCPI_ *
57 std::pow(1.0 + model_->infdk(index_)->termStructure()->zeroRate(arguments_.fixDate, Period(0, Days)), t);
58 m = arguments_.index->fixing(arguments_.fixDate);
59 Real Ht = Hy(index_).eval(*model_, t);
60 Real v = Ht * Ht * zetay(index_).eval(*model_, t) -
61 2.0 * Ht * integral(*model_, P(Hy(index_), ay(index_), ay(index_)), 0.0, t) +
62 integral(*model_, P(Hy(index_), Hy(index_), ay(index_), ay(index_)), 0.0, t);
63
64 Size irIdx = model_->ccyIndex(model_->infdk(index_)->currency());
65 Real discount = model_->irlgm1f(irIdx)->termStructure()->discount(arguments_.payDate);
66
67 results_.value = nTilde * blackFormula(arguments_.type, kTilde, m, std::sqrt(v), discount);
68
69} // calculate()
70
71} // namespace QuantExt
analytic dk cpi cap floor engine
const Instrument::results * results_
Definition: cdsoption.cpp:81
AnalyticDkCpiCapFloorEngine(const QuantLib::ext::shared_ptr< CrossAssetModel > &model, const Size index, const Real baseCPI)
const QuantLib::ext::shared_ptr< CrossAssetModel > model_
analytics for the cross asset model
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)
INF H component. May relate to real rate portion of JY model or z component of DK model.
QuantLib::Real eval(const CrossAssetModel &x, const QuantLib::Real t) const
INF alpha component. May relate to real rate portion of JY model or z component of DK model.
INF zeta component. May relate to real rate portion of JY model or z component of DK model.
Real eval(const CrossAssetModel &x, const Real t) const
Swap::arguments * arguments_