Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
dynamicyoyoptionletvolatilitystructure.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 {
23 const QuantLib::ext::shared_ptr<YoYOptionletVolatilitySurface>& source, ReactionToTimeDecay decayMode)
24 : YoYOptionletVolatilitySurface(source->settlementDays(), source->calendar(), source->businessDayConvention(),
25 source->dayCounter(), source->observationLag(), source->frequency(),
26 source->indexIsInterpolated(), source->volatilityType(), source->displacement()),
27 source_(source), decayMode_(decayMode), originalReferenceDate_(source->referenceDate()) {
28 // Set extrapolation to source's extrapolation initially
29 enableExtrapolation(source->allowsExtrapolation());
30}
31
32Rate DynamicYoYOptionletVolatilitySurface::minStrike() const { return source_->minStrike(); }
33
34Rate DynamicYoYOptionletVolatilitySurface::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
50Volatility DynamicYoYOptionletVolatilitySurface::volatilityImpl(Time optionTime, Rate strike) const {
52 return source_->volatility(optionTime, strike);
53 }
54
55 // TODO: check validity of ForwardVariance option before using it.
57 "ForwardVariance not yet supported for DynamicYoYOptionletVolatilityStructure");
59 // FIXME
60 Real t0 = timeFromBase(referenceDate());
61 Volatility varToRef = source_->volatility(t0, strike) * source_->volatility(t0, strike) * t0;
62 Volatility varToOptTime =
63 source_->volatility(optionTime, strike) * source_->volatility(optionTime, strike) * optionTime;
64 return std::sqrt((varToOptTime - varToRef) / (optionTime - t0));
65 }
66
67 QL_FAIL("Unexpected decay mode (" << decayMode_ << ")");
68}
69} // namespace QuantExt
Volatility volatilityImpl(Time optionTime, Rate strike) const override
DynamicYoYOptionletVolatilitySurface(const QuantLib::ext::shared_ptr< YoYOptionletVolatilitySurface > &source, ReactionToTimeDecay decayMode=ConstantVariance)
const QuantLib::ext::shared_ptr< YoYOptionletVolatilitySurface > source_
dynamic yoy inflation optionlet volatility structure
ReactionToTimeDecay
Reaction to Time Decay.
@ ConstantVariance
@ ForwardForwardVariance