Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cpivolatilitystructure.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 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
19#include <ql/termstructures/inflationtermstructure.hpp>
22
23namespace QuantExt {
24
25CPIVolatilitySurface::CPIVolatilitySurface(QuantLib::Natural settlementDays, const QuantLib::Calendar& cal,
26 QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter& dc,
27 const QuantLib::Period& observationLag, QuantLib::Frequency frequency,
28 bool indexIsInterpolated, const QuantLib::Date& startDate,
29 QuantLib::VolatilityType volType, double displacement)
30 : QuantLib::CPIVolatilitySurface(settlementDays, cal, bdc, dc, observationLag, frequency, indexIsInterpolated),
31 volType_(volType), displacement_(displacement), capFloorStartDate_(startDate) {}
32
34 if (capFloorStartDate_ == QuantLib::Date()) {
35 return referenceDate();
36 } else {
37 return capFloorStartDate_;
38 }
39}
40
41QuantLib::Date CPIVolatilitySurface::optionDateFromTenor(const QuantLib::Period& tenor) const {
42 return calendar().advance(capFloorStartDate(), tenor, businessDayConvention());
43}
44
45QuantLib::Date CPIVolatilitySurface::baseDate() const {
46 // Depends on interpolation, or not, of observed index
47 // and observation lag with which it was built.
48 // We want this to work even if the index does not
49 // have a term structure.
50 if (indexIsInterpolated()) {
51 return capFloorStartDate() - observationLag();
52 } else {
53 return QuantLib::inflationPeriod(capFloorStartDate() - observationLag(), frequency()).first;
54 }
55}
56
57double CPIVolatilitySurface::fixingTime(const QuantLib::Date& maturityDate) const {
58 return timeFromReference(ZeroInflation::fixingDate(maturityDate, observationLag(), frequency(), indexIsInterpolated()));
59}
60
61QuantLib::Volatility CPIVolatilitySurface::volatility(const QuantLib::Date& maturityDate, QuantLib::Rate strike,
62 const QuantLib::Period& obsLag, bool extrapolate) const {
63 if (strike == QuantLib::Null<QuantLib::Real>()) {
64 strike = atmStrike(maturityDate, obsLag);
65 }
66 return QuantLib::CPIVolatilitySurface::volatility(maturityDate, strike, obsLag, extrapolate);
67}
68
69} // namespace QuantExt
QuantLib::Date baseDate() const override
base date will be in the past
virtual QuantLib::Real atmStrike(const QuantLib::Date &maturity, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days)) const =0
QuantLib::Date capFloorStartDate() const
virtual double fixingTime(const QuantLib::Date &maturityDate) const
Computes the expiry time from the capFloorStartDate()
CPIVolatilitySurface(QuantLib::Natural settlementDays, const QuantLib::Calendar &, QuantLib::BusinessDayConvention bdc, const QuantLib::DayCounter &dc, const QuantLib::Period &observationLag, QuantLib::Frequency frequency, bool indexIsInterpolated, const QuantLib::Date &capFloorStartDate=QuantLib::Date(), QuantLib::VolatilityType volType=QuantLib::ShiftedLognormal, double displacement=0.0)
QuantLib::Volatility volatility(const QuantLib::Date &maturityDate, QuantLib::Rate strike, const QuantLib::Period &obsLag=QuantLib::Period(-1, QuantLib::Days), bool extrapolate=false) const override
QuantLib::Date optionDateFromTenor(const QuantLib::Period &tenor) const override
Computes the expiry date from the capFloorStartDate()
interpolated correlation term structure
some inflation related utilities.
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
Definition: inflation.cpp:183