Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swaptionvolconstantspread.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2017 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
21#include <iostream>
22
23namespace QuantExt {
24
25Volatility ConstantSpreadSmileSection::volatilityImpl(Rate strike) const {
26 Real t = exerciseTime();
27 Real s = section_->volatility(strike) - section_->volatility(atmStrike_);
28 Real v = atm_->volatility(t, swapLength_, strike);
29 return v + s;
30}
31
32QuantLib::ext::shared_ptr<SmileSection> SwaptionVolatilityConstantSpread::smileSectionImpl(Time optionTime,
33 Time swapLength) const {
34 return QuantLib::ext::make_shared<ConstantSpreadSmileSection>(atm_, cube_, optionTime, swapLength);
35}
36
37Volatility SwaptionVolatilityConstantSpread::volatilityImpl(Time optionTime, Time swapLength, Rate strike) const {
38 if (strike == Null<Real>())
39 return atm_->volatility(optionTime, swapLength, 0.0);
40 else {
41 return smileSectionImpl(optionTime, swapLength)->volatility(strike);
42 }
43}
44
46 atm_->update();
47 cube_->update();
48 update();
49}
50
51} // namespace QuantExt
const QuantLib::ext::shared_ptr< SmileSection > section_
const Handle< SwaptionVolatilityStructure > atm_
Volatility volatilityImpl(Rate strike) const override
Handle< SwaptionVolatilityStructure > cube_
Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const override
QuantLib::ext::shared_ptr< SmileSection > smileSectionImpl(Time optionTime, Time swapLength) const override
Handle< SwaptionVolatilityStructure > atm_
swaption cube that combines an ATM matrix and vol spreads from a cube