Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
atmadjustedsmilesection.hpp
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#pragma once
20
21#include <ql/termstructures/volatility/smilesection.hpp>
22
23namespace QuantExt {
24
25class AtmAdjustedSmileSection : public QuantLib::SmileSection {
26public:
27 AtmAdjustedSmileSection(const QuantLib::ext::shared_ptr<QuantLib::SmileSection>& base, const QuantLib::Real baseAtmLevel,
28 const QuantLib::Real targetAtmLevel)
29 : SmileSection(), base_(base), baseAtmLevel_(baseAtmLevel), targetAtmLevel_(targetAtmLevel) {}
30 QuantLib::Real minStrike() const override { return base_->minStrike(); }
31 QuantLib::Real maxStrike() const override { return base_->maxStrike(); }
32 QuantLib::Real atmLevel() const override { return targetAtmLevel_; }
33 const QuantLib::Date& exerciseDate() const override { return base_->exerciseDate(); }
34 QuantLib::VolatilityType volatilityType() const override { return base_->volatilityType(); }
35 QuantLib::Rate shift() const override { return base_->shift(); }
36 const QuantLib::Date& referenceDate() const override { return base_->referenceDate(); }
37 QuantLib::Time exerciseTime() const override { return base_->exerciseTime(); }
38 const QuantLib::DayCounter& dayCounter() const override { return base_->dayCounter(); }
39
40private:
41 QuantLib::Volatility volatilityImpl(QuantLib::Rate strike) const override {
42 if (strike == QuantLib::Null<QuantLib::Real>()) {
43 return base_->volatility(baseAtmLevel_);
44 }
45 // just a moneyness, but no vol adjustment, so this is only suitable for normal vols
46 return base_->volatility(strike + baseAtmLevel_ - targetAtmLevel_);
47 };
48
49 QuantLib::ext::shared_ptr<QuantLib::SmileSection> base_;
50 QuantLib::Real baseAtmLevel_;
51 QuantLib::Real targetAtmLevel_;
52};
53
54} // namespace QuantExt
QuantLib::Real minStrike() const override
AtmAdjustedSmileSection(const QuantLib::ext::shared_ptr< QuantLib::SmileSection > &base, const QuantLib::Real baseAtmLevel, const QuantLib::Real targetAtmLevel)
QuantLib::Rate shift() const override
QuantLib::VolatilityType volatilityType() const override
QuantLib::Real maxStrike() const override
const QuantLib::DayCounter & dayCounter() const override
QuantLib::Real atmLevel() const override
QuantLib::Volatility volatilityImpl(QuantLib::Rate strike) const override
QuantLib::ext::shared_ptr< QuantLib::SmileSection > base_
const QuantLib::Date & exerciseDate() const override
QuantLib::Time exerciseTime() const override
const QuantLib::Date & referenceDate() const override