Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
blackvolsurfaceabsolute.hpp
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
19/*! \file blackvolsurfaceabsolute.hpp
20 \brief Black volatility surface based on absolute quotes
21*/
22
23#pragma once
24
25#include <ql/experimental/fx/deltavolquote.hpp>
26#include <ql/math/interpolation.hpp>
27#include <ql/option.hpp>
28#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
29#include <ql/termstructures/yieldtermstructure.hpp>
30#include <ql/time/calendar.hpp>
31#include <ql/time/daycounter.hpp>
32
33namespace QuantExt {
34
35using namespace QuantLib;
36
37class BlackVolatilitySurfaceAbsolute : public BlackVolatilityTermStructure{
38public:
41 Date referenceDate, const std::vector<Date>& dates, const std::vector<std::vector<Real>>& strikes,
42 const std::vector<std::vector<Real>>& strikeQuotes, const DayCounter& dayCounter, const Calendar& calendar,
43 const Handle<Quote>& spot, const Size spotDays, const Calendar spotCalendar,
44 const Handle<YieldTermStructure>& domesticTS, const Handle<YieldTermStructure>& foreignTS,
45 const DeltaVolQuote::DeltaType dt = DeltaVolQuote::DeltaType::Spot,
46 const DeltaVolQuote::AtmType at = DeltaVolQuote::AtmType::AtmDeltaNeutral,
47 const Period& switchTenor = 2 * Years, const DeltaVolQuote::DeltaType ltdt = DeltaVolQuote::DeltaType::Fwd,
48 const DeltaVolQuote::AtmType ltat = DeltaVolQuote::AtmType::AtmDeltaNeutral,
49 const SmileInterpolation smileInterpolation = SmileInterpolation::Cubic, const bool flatExtrapolation = true);
50
51 Date maxDate() const override { return Date::maxDate(); }
52 Real minStrike() const override { return 0; }
53 Real maxStrike() const override { return QL_MAX_REAL; }
54
55 const std::vector<QuantLib::Date>& dates() const { return dates_; }
56 const std::vector<std::vector<Real>>& strikes() const { return strikes_; }
57 const std::vector<std::vector<Real>>& strikeQuotes() const { return strikeQuotes_; }
58 const Handle<Quote>& spot() const { return spot_; }
59 const Handle<YieldTermStructure>& domesticTS() const { return domesticTS_; }
60 const Handle<YieldTermStructure>& foreignTS() const { return foreignTS_; }
61 DeltaVolQuote::DeltaType deltaType() const { return dt_; }
62 DeltaVolQuote::AtmType atmType() const { return at_; }
63 const Period& switchTenor() const { return switchTenor_; }
64 DeltaVolQuote::DeltaType longTermDeltaType() const { return ltdt_; }
65 DeltaVolQuote::AtmType longTermAtmType() const { return ltat_; }
67
68private:
69 Volatility blackVolImpl(Time t, Real strike) const override;
70 void update() override;
71
72 std::vector<Date> dates_;
73 std::vector<std::vector<Real>> strikes_;
74 std::vector<std::vector<Real>> strikeQuotes_;
75 Handle<Quote> spot_;
77 Calendar spotCalendar_;
78 Handle<YieldTermStructure> domesticTS_;
79 Handle<YieldTermStructure> foreignTS_;
80 DeltaVolQuote::DeltaType dt_;
81 DeltaVolQuote::AtmType at_;
83 DeltaVolQuote::DeltaType ltdt_;
84 DeltaVolQuote::AtmType ltat_;
86 std::vector<QuantLib::ext::shared_ptr<Interpolation>> interpolation_;
88
89 mutable std::vector<Real> expiryTimes_;
90 mutable std::vector<Date> settlementDates_;
91 mutable std::map<std::pair<Real, Real>, Real> cachedInterpolatedVols_;
92};
93
94} // namespace QuantExt
std::vector< QuantLib::ext::shared_ptr< Interpolation > > interpolation_
DeltaVolQuote::DeltaType longTermDeltaType() const
const std::vector< std::vector< Real > > & strikes() const
std::vector< std::vector< Real > > strikes_
DeltaVolQuote::AtmType longTermAtmType() const
const std::vector< std::vector< Real > > & strikeQuotes() const
const Handle< YieldTermStructure > & domesticTS() const
std::vector< std::vector< Real > > strikeQuotes_
const Handle< YieldTermStructure > & foreignTS() const
DeltaVolQuote::DeltaType deltaType() const
Volatility blackVolImpl(Time t, Real strike) const override
const std::vector< QuantLib::Date > & dates() const
std::map< std::pair< Real, Real >, Real > cachedInterpolatedVols_