Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvolconstantspread.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2021 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
21using namespace QuantLib;
22
23namespace QuantExt {
24
25BlackVolatilityConstantSpread::BlackVolatilityConstantSpread(const Handle<BlackVolTermStructure>& atm,
26 const Handle<BlackVolTermStructure>& surface)
27 : BlackVolTermStructure(0, atm->calendar(), atm->businessDayConvention(), atm->dayCounter()), atm_(atm),
28 surface_(surface) {
29 enableExtrapolation(atm->allowsExtrapolation());
30 registerWith(atm);
31 registerWith(surface);
32}
33
35 return atm_->dayCounter();
36}
37
39 return atm_->maxDate();
40}
41
43 return atm_->maxTime();
44}
45
47 return atm_->referenceDate();
48}
49
51 return atm_->calendar();
52}
53
55 return atm_->settlementDays();
56}
57
59 return surface_->minStrike();
60}
61
63 return surface_->maxStrike();
64}
65
67 atm_->update();
68 update();
69}
70
71Volatility BlackVolatilityConstantSpread::blackVolImpl(Time t, Rate strike) const {
72 Real s = surface_->blackVol(t, strike, true) - surface_->blackVol(t, Null<Real>(), true);
73 Real v = atm_->blackVol(t, Null<Real>(), true);
74 return v + s;
75}
76
77Real BlackVolatilityConstantSpread::blackVarianceImpl(Time t, Real strike) const {
78 Real vol = blackVolImpl(t, strike);
79 return vol * vol * t;
80}
81
82
83} // QuantExt
surface that combines an ATM curve and vol spreads from a surface
BlackVolatilityConstantSpread(const Handle< BlackVolTermStructure > &atm, const Handle< BlackVolTermStructure > &surface)
Handle< BlackVolTermStructure > surface_
Real blackVarianceImpl(Time t, Real strike) const override
Volatility blackVolImpl(Time t, Rate strike) const override