Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
dynamicoptionletvolatilitystructure.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
20
21namespace QuantExt {
23 const QuantLib::ext::shared_ptr<OptionletVolatilityStructure>& source, Natural settlementDays, const Calendar& calendar,
24 ReactionToTimeDecay decayMode)
25 : OptionletVolatilityStructure(settlementDays, calendar, source->businessDayConvention(), source->dayCounter()),
26 source_(source), decayMode_(decayMode), originalReferenceDate_(source->referenceDate()),
27 volatilityType_(source->volatilityType()), displacement_(source->displacement()) {
29 "ForwardVariance not yet supported for DynamicOptionletVolatilityStructure");
30 enableExtrapolation(source->allowsExtrapolation());
31}
32
33Rate DynamicOptionletVolatilityStructure::minStrike() const { return source_->minStrike(); }
34
35Rate DynamicOptionletVolatilityStructure::maxStrike() const { return source_->maxStrike(); }
36
39 return source_->maxDate();
40 }
41
43 return Date(std::min(Date::maxDate().serialNumber(), referenceDate().serialNumber() -
44 originalReferenceDate_.serialNumber() +
45 source_->maxDate().serialNumber()));
46 }
47
48 QL_FAIL("unexpected decay mode (" << decayMode_ << ")");
49}
50
51void DynamicOptionletVolatilityStructure::update() { TermStructure::update(); }
52
53QuantLib::ext::shared_ptr<SmileSection> DynamicOptionletVolatilityStructure::smileSectionImpl(Time optionTime) const {
54 return source_->smileSection(optionTime);
55}
56
57Volatility DynamicOptionletVolatilityStructure::volatilityImpl(Time optionTime, Rate strike) const {
58 return source_->volatility(optionTime, strike);
59 // tentative ForwardForwardVariance implementation:
60 // if (decayMode_ == ForwardForwardVariance) {
61 // Real timeToRef = source_->timeFromReference(referenceDate());
62 // Real varToRef = source_->blackVariance(timeToRef, strike);
63 // Real varToOptTime = source_->blackVariance(timeToRef + optionTime, strike);
64 // return std::sqrt((varToOptTime - varToRef) / optionTime);
65 // }
66}
67} // namespace QuantExt
const QuantLib::ext::shared_ptr< OptionletVolatilityStructure > source_
Volatility volatilityImpl(Time optionTime, Rate strike) const override
DynamicOptionletVolatilityStructure(const QuantLib::ext::shared_ptr< OptionletVolatilityStructure > &source, Natural settlementDays, const Calendar &calendar, ReactionToTimeDecay decayMode=ConstantVariance)
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime) const override
dynamic optionlet volatility structure
ReactionToTimeDecay
Reaction to Time Decay.
@ ConstantVariance
@ ForwardForwardVariance