Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
dynamiccpivolatilitystructure.cpp
Go to the documentation of this file.
1/*
2Copyright (C) 2019 Quaternion Risk Management Ltd
3All rights reserved.
4
5This file is part of ORE, a free-software/open-source library
6for transparent pricing and risk analysis - http://opensourcerisk.org
7
8ORE is free software: you can redistribute it and/or modify it
9under the terms of the Modified BSD License. You should have received a
10copy of the license along with this program.
11The license is also available online at <http://opensourcerisk.org>
12
13This program is distributed on the basis that it will form a useful
14contribution to risk analytics and model standardisation, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20
21namespace QuantExt {
22DynamicCPIVolatilitySurface::DynamicCPIVolatilitySurface(const QuantLib::ext::shared_ptr<CPIVolatilitySurface>& source,
23 ReactionToTimeDecay decayMode)
24 : CPIVolatilitySurface(source->settlementDays(), source->calendar(), source->businessDayConvention(),
25 source->dayCounter(), source->observationLag(), source->frequency(),
26 source->indexIsInterpolated()),
27 source_(source), decayMode_(decayMode), originalReferenceDate_(source->referenceDate()) {
28 // Set extrapolation to source's extrapolation initially
29 enableExtrapolation(source->allowsExtrapolation());
30}
31
32Rate DynamicCPIVolatilitySurface::minStrike() const { return source_->minStrike(); }
33
34Rate DynamicCPIVolatilitySurface::maxStrike() const { return source_->maxStrike(); }
35
38 return source_->maxDate();
39 }
40
42 return Date(std::min(Date::maxDate().serialNumber(), referenceDate().serialNumber() -
43 originalReferenceDate_.serialNumber() +
44 source_->maxDate().serialNumber()));
45 }
46
47 QL_FAIL("unexpected decay mode (" << decayMode_ << ")");
48}
49
50void DynamicCPIVolatilitySurface::update() { TermStructure::update(); }
51
52Volatility DynamicCPIVolatilitySurface::volatilityImpl(Time length, Rate strike) const {
54 // FIXME!
55 Date m = referenceDate() + int(floor(365.25 * length)) * Days;
56 return source_->volatility(m, strike, source_->observationLag());
57 }
58
59 // TODO: check validity of ForwardVariance option before using it.
61 "ForwardVariance not yet supported for DynamicCPiVolatilityStructure");
62 // if (decayMode_ == ForwardForwardVariance) {
63 // Volatility varToRef = source_->totalVariance(referenceDate(), strike, source_->observationLag());
64 // Volatility varToOptTime = source_->totalVariance(optionDate, strike, source_->observationLag());
65 // return std::sqrt((varToOptTime - varToRef) / timeFromReference(optionDate));
66 // }
67
68 QL_FAIL("Unexpected decay mode (" << decayMode_ << ")");
69}
70} // namespace QuantExt
DynamicCPIVolatilitySurface(const QuantLib::ext::shared_ptr< CPIVolatilitySurface > &source, ReactionToTimeDecay decayMode=ConstantVariance)
Volatility volatilityImpl(Time length, Rate strike) const override
const QuantLib::ext::shared_ptr< CPIVolatilitySurface > source_
dynamic zero inflation volatility structure
ReactionToTimeDecay
Reaction to Time Decay.
@ ConstantVariance
@ ForwardForwardVariance