52 {
54
57
58 QL_DEPRECATED_DISABLE_WARNING
59 bool isInterpolated =
arguments_.observationInterpolation == CPI::Linear ||
60 (
arguments_.observationInterpolation == CPI::AsIndex && index->interpolated());
61 QL_DEPRECATED_ENABLE_WARNING
62
64 index->frequency(), isInterpolated);
65
67 index->frequency(), isInterpolated);
68
69 Real optionBaseFixing =
arguments_.baseCPI == Null<Real>()
73
76
77 Time timeToMaturityFromInception =
78 inflationYearFraction(index->frequency(), isInterpolated, index->zeroInflationTermStructure()->dayCounter(),
79 optionBaseDate, optionObservationDate);
80
81 Real atmGrowth = atmCPIFixing / optionBaseFixing;
82 Real strike = std::pow(1.0 +
arguments_.strike, timeToMaturityFromInception);
83
85 auto observationPeriod = inflationPeriod(optionObservationDate, index->frequency());
86 auto requiredFixing = isInterpolated ? observationPeriod.first : observationPeriod.second + 1 * Days;
87
88
89
90 Real stdDev = 0.0;
91 Real vol = 0.0;
92 Real strikeZeroRate = 0.0;
93 Real ttmFromSurfaceBaseDate = 0.0;
94 Real surfaceBaseFixing = 0.0;
95 if (requiredFixing > lastKnownFixingDate) {
96
97
98
99 surfaceBaseFixing =
102 ttmFromSurfaceBaseDate =
104 index->zeroInflationTermStructure()->dayCounter(),
volatilitySurface_->baseDate(), optionObservationDate);
105 strikeZeroRate =
pow(optionBaseFixing / surfaceBaseFixing * strike, 1.0 / ttmFromSurfaceBaseDate) - 1.0;
106 vol =
volatilitySurface_->volatility(optionObservationDate, strikeZeroRate, 0 * Days);
108 auto ttm =
111 stdDev = std::sqrt(ttm * vol * vol);
112 } else {
113 stdDev = std::sqrt(
volatilitySurface_->totalVariance(optionObservationDate, strikeZeroRate, 0 * Days));
114 }
115 }
117
119 results_.additionalResults[
"strike"] = strike;
120 results_.additionalResults[
"forward"] = atmGrowth;
121 results_.additionalResults[
"stdDev"] = stdDev;
122 results_.additionalResults[
"discount"] = d;
123 results_.additionalResults[
"vol"] = vol;
124 results_.additionalResults[
"timeToExpiry"] = stdDev * stdDev / (vol * vol);
125 results_.additionalResults[
"BaseDate_trade"] = optionBaseDate;
127 results_.additionalResults[
"FixingDate"] = optionObservationDate;
128 results_.additionalResults[
"PaymentDate"] = maturity;
129 results_.additionalResults[
"BaseCPI_trade"] = optionBaseFixing;
130 results_.additionalResults[
"BaseCPI_today"] = surfaceBaseFixing;
131 results_.additionalResults[
"ForwardCPI"] = atmCPIFixing;
133 results_.additionalResults[
"strike_asof_today"] = strikeZeroRate;
134 results_.additionalResults[
"timeToExpiry_from_trade_baseDate"] = timeToMaturityFromInception;
135 results_.additionalResults[
"timeToExpiry_from_todays_baseDate"] = ttmFromSurfaceBaseDate;
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154}
const Instrument::results * results_
virtual double optionPriceImpl(QuantLib::Option::Type type, double forward, double strike, double stdDev, double discount) const =0
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
QuantLib::Date lastAvailableFixing(const QuantLib::ZeroInflationIndex &index, const QuantLib::Date &asof)
Check if today - availabilityLag is already known, otherwise return the fixingDate of the previous fi...
QuantLib::Rate cpiFixing(const QuantLib::ext::shared_ptr< QuantLib::ZeroInflationIndex > &index, const QuantLib::Date &maturity, const QuantLib::Period &obsLag, bool interpolated)
Computes a CPI fixing giving an zeroIndex, with interpolation if needed.
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)
Swap::arguments * arguments_