Skip to content

Commit c25768a

Browse files
pcaspersjenkins
authored andcommitted
QPR-11796 extrapolate flat by default
1 parent 5c6ff81 commit c25768a

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

QuantExt/qle/termstructures/blackvolsurfaceabsolute.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <qle/termstructures/blackvolsurfaceabsolute.hpp>
20+
#include <qle/math/flatextrapolation.hpp>
2021

2122
#include <ql/experimental/fx/blackdeltacalculator.hpp>
2223
#include <ql/math/comparison.hpp>
@@ -28,17 +29,17 @@
2829
namespace QuantExt {
2930

3031
BlackVolatilitySurfaceAbsolute::BlackVolatilitySurfaceAbsolute(
31-
Date referenceDate, const std::vector<Date>& dates,
32-
const std::vector<std::vector<Real>>& strikes, const std::vector<std::vector<Real>>& strikeQuotes,
33-
const DayCounter& dayCounter, const Calendar& calendar,
32+
Date referenceDate, const std::vector<Date>& dates, const std::vector<std::vector<Real>>& strikes,
33+
const std::vector<std::vector<Real>>& strikeQuotes, const DayCounter& dayCounter, const Calendar& calendar,
3434
const Handle<Quote>& spot, const Size spotDays, const Calendar spotCalendar,
3535
const Handle<YieldTermStructure>& domesticTS, const Handle<YieldTermStructure>& foreignTS,
3636
const DeltaVolQuote::DeltaType dt, const DeltaVolQuote::AtmType at, const Period& switchTenor,
37-
const DeltaVolQuote::DeltaType ltdt, const DeltaVolQuote::AtmType ltat, const SmileInterpolation smileInterpolation)
37+
const DeltaVolQuote::DeltaType ltdt, const DeltaVolQuote::AtmType ltat, const SmileInterpolation smileInterpolation,
38+
const bool flatExtrapolation)
3839
: BlackVolatilityTermStructure(referenceDate, calendar, Following, dayCounter), dates_(dates), strikes_(strikes),
39-
strikeQuotes_(strikeQuotes), spot_(spot), spotDays_(spotDays),
40-
spotCalendar_(spotCalendar), domesticTS_(domesticTS), foreignTS_(foreignTS), dt_(dt), at_(at),
41-
switchTenor_(switchTenor), ltdt_(ltdt), ltat_(ltat), smileInterpolation_(smileInterpolation) {
40+
strikeQuotes_(strikeQuotes), spot_(spot), spotDays_(spotDays), spotCalendar_(spotCalendar),
41+
domesticTS_(domesticTS), foreignTS_(foreignTS), dt_(dt), at_(at), switchTenor_(switchTenor), ltdt_(ltdt),
42+
ltat_(ltat), smileInterpolation_(smileInterpolation), flatExtrapolation_(flatExtrapolation) {
4243

4344
// checks
4445

@@ -92,6 +93,10 @@ BlackVolatilitySurfaceAbsolute::BlackVolatilitySurfaceAbsolute(
9293
QL_FAIL("BlackVolatilitySurfaceAbsolute: Invalid interpolation type.");
9394
}
9495
}
96+
if (flatExtrapolation_) {
97+
interpolation_[i] = boost::make_shared<FlatExtrapolation>(interpolation_[i]);
98+
interpolation_[i]->enableExtrapolation();
99+
}
95100
}
96101

97102
// register with observables

QuantExt/qle/termstructures/blackvolsurfaceabsolute.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class BlackVolatilitySurfaceAbsolute : public BlackVolatilityTermStructure{
4646
const DeltaVolQuote::AtmType at = DeltaVolQuote::AtmType::AtmDeltaNeutral,
4747
const Period& switchTenor = 2 * Years, const DeltaVolQuote::DeltaType ltdt = DeltaVolQuote::DeltaType::Fwd,
4848
const DeltaVolQuote::AtmType ltat = DeltaVolQuote::AtmType::AtmDeltaNeutral,
49-
const SmileInterpolation smileInterpolation = SmileInterpolation::Cubic);
49+
const SmileInterpolation smileInterpolation = SmileInterpolation::Cubic, const bool flatExtrapolation = true);
5050

5151
Date maxDate() const override { return Date::maxDate(); }
5252
Real minStrike() const override { return 0; }
@@ -84,6 +84,7 @@ class BlackVolatilitySurfaceAbsolute : public BlackVolatilityTermStructure{
8484
DeltaVolQuote::AtmType ltat_;
8585
SmileInterpolation smileInterpolation_;
8686
std::vector<boost::shared_ptr<Interpolation>> interpolation_;
87+
bool flatExtrapolation_;
8788

8889
mutable Real switchTime_, settlDomDisc_, settlForDisc_, settlLag_;
8990
mutable std::vector<Real> expiryTimes_;

0 commit comments

Comments
 (0)