Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
proxyswaptionvolatility.cpp
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
22
23namespace QuantExt {
24
25using namespace QuantLib;
26
27ProxySwaptionVolatility::ProxySwaptionVolatility(const QuantLib::Handle<SwaptionVolatilityStructure>& baseVol,
28 QuantLib::ext::shared_ptr<SwapIndex> baseSwapIndexBase,
29 QuantLib::ext::shared_ptr<SwapIndex> baseShortSwapIndexBase,
30 QuantLib::ext::shared_ptr<SwapIndex> targetSwapIndexBase,
31 QuantLib::ext::shared_ptr<SwapIndex> targetShortSwapIndexBase)
32 : SwaptionVolatilityStructure(baseVol->businessDayConvention(), baseVol->dayCounter()), baseVol_(baseVol),
33 baseSwapIndexBase_(baseSwapIndexBase), baseShortSwapIndexBase_(baseShortSwapIndexBase),
34 targetSwapIndexBase_(targetSwapIndexBase), targetShortSwapIndexBase_(targetShortSwapIndexBase) {
35 enableExtrapolation(baseVol->allowsExtrapolation());
36}
37
38QuantLib::ext::shared_ptr<SmileSection> ProxySwaptionVolatility::smileSectionImpl(Time optionTime, Time swapLength) const {
39 // imply option date from option time
40 Date optionDate = lowerDate(optionTime, referenceDate(), dayCounter());
41 // imply swap tenor from swap length
42 Period swapTenor = tenorFromLength(swapLength);
43 return smileSectionImpl(optionDate, swapTenor);
44}
45
46QuantLib::ext::shared_ptr<SmileSection> ProxySwaptionVolatility::smileSectionImpl(const Date& optionDate,
47 const Period& swapTenor) const {
48 Real baseAtmLevel =
49 swapTenor > baseShortSwapIndexBase_->tenor()
50 ? baseSwapIndexBase_->clone(swapTenor)->fixing(baseSwapIndexBase_->fixingCalendar().adjust(optionDate))
51 : baseShortSwapIndexBase_->clone(swapTenor)->fixing(
52 baseShortSwapIndexBase_->fixingCalendar().adjust(optionDate));
53 Real targetAtmLevel =
54 swapTenor > targetShortSwapIndexBase_->tenor()
55 ? targetSwapIndexBase_->clone(swapTenor)->fixing(targetSwapIndexBase_->fixingCalendar().adjust(optionDate))
56 : targetShortSwapIndexBase_->clone(swapTenor)->fixing(
57 targetShortSwapIndexBase_->fixingCalendar().adjust(optionDate));
58 return QuantLib::ext::make_shared<AtmAdjustedSmileSection>(baseVol_->smileSection(optionDate, swapTenor, true),
59 baseAtmLevel, targetAtmLevel);
60}
61
62Volatility ProxySwaptionVolatility::volatilityImpl(Time optionTime, Time swapLength, Rate strike) const {
63 return smileSection(optionTime, swapLength)->volatility(strike);
64}
65
66} // namespace QuantExt
QuantLib::Volatility volatilityImpl(QuantLib::Time optionTime, QuantLib::Time swapLength, QuantLib::Rate strike) const override
QuantLib::ext::shared_ptr< QuantLib::SwapIndex > baseSwapIndexBase_
QuantLib::ext::shared_ptr< QuantLib::SmileSection > smileSectionImpl(const QuantLib::Date &optionDate, const QuantLib::Period &swapTenor) const override
ProxySwaptionVolatility(const QuantLib::Handle< SwaptionVolatilityStructure > &baseVol, QuantLib::ext::shared_ptr< QuantLib::SwapIndex > baseSwapIndexBase, QuantLib::ext::shared_ptr< QuantLib::SwapIndex > baseShortSwapIndexBase, QuantLib::ext::shared_ptr< QuantLib::SwapIndex > targetSwapIndexBase, QuantLib::ext::shared_ptr< QuantLib::SwapIndex > targetShortSwapIndexBase)
QuantLib::ext::shared_ptr< QuantLib::SwapIndex > baseShortSwapIndexBase_
QuantLib::Handle< QuantLib::SwaptionVolatilityStructure > baseVol_
QuantLib::ext::shared_ptr< QuantLib::SwapIndex > targetSwapIndexBase_
QuantLib::ext::shared_ptr< QuantLib::SwapIndex > targetShortSwapIndexBase_
const QuantLib::Date & referenceDate() const override
QuantLib::Period tenorFromLength(const QuantLib::Real length)
Definition: time.cpp:94
QuantLib::Date lowerDate(const Real t, const QuantLib::Date &refDate, const QuantLib::DayCounter &dc)
Definition: time.cpp:66
moneyness-adjusted swaption vol for normal vols
time related utilities.