19#include <ql/math/interpolations/backwardflatinterpolation.hpp>
20#include <ql/math/interpolations/linearinterpolation.hpp>
21#include <ql/time/calendars/nullcalendar.hpp>
29 const Date& referenceDate,
const std::vector<Date>& dates,
const std::vector<Volatility>& atmVols,
30 const std::vector<Volatility>& rr,
const std::vector<Volatility>& bf,
const DayCounter& dayCounter,
31 const Calendar& cal,
const Handle<Quote>& fxSpot,
const Handle<YieldTermStructure>& domesticTS,
32 const Handle<YieldTermStructure>& foreignTS,
bool requireMonotoneVariance,
const DeltaVolQuote::AtmType atmType,
33 const DeltaVolQuote::DeltaType deltaType,
const Real delta,
const Period& switchTenor,
34 const DeltaVolQuote::AtmType longTermAtmType,
const DeltaVolQuote::DeltaType longTermDeltaType)
35 : BlackVolatilityTermStructure(referenceDate, cal), times_(dates.size()), dayCounter_(dayCounter), fxSpot_(fxSpot),
36 domesticTS_(domesticTS), foreignTS_(foreignTS),
37 atmCurve_(referenceDate, dates, atmVols, dayCounter, requireMonotoneVariance), rr_(rr), bf_(bf),
38 atmType_(atmType), deltaType_(deltaType), delta_(delta), switchTenor_(switchTenor),
39 longTermAtmType_(longTermAtmType), longTermDeltaType_(longTermDeltaType) {
41 QL_REQUIRE(dates.size() >= 1,
"at least 1 date required");
44 QL_REQUIRE(dates.size() == rr.size(),
"mismatch between date vector and RR vector");
45 QL_REQUIRE(dates.size() == bf.size(),
"mismatch between date vector and BF vector");
48 for (Size i = 0; i < dates.size(); i++) {
49 QL_REQUIRE(referenceDate < dates[i],
"Dates must be greater than reference date");
50 times_[i] = timeFromReference(dates[i]);
52 QL_REQUIRE(
times_[i] >
times_[i - 1],
"dates must be sorted unique!");
57 if (dates.size() > 1) {
74 Volatility atm =
atmCurve_.blackVol(t, 0);
84 QL_REQUIRE(t >= 0,
"FxBlackVolatilitySurface::blackVolSmileImpl(): non-negative expiry time expected");
86 }
else if (t <
times_.back()) {
103 if (strike == 0 || strike == Null<Real>())
110 Time t, Volatility atm,
112 Volatility bf)
const {
113 QL_REQUIRE(t > 0,
"FxBlackVannaVolgaVolatilitySurface::blackVolSmileImpl(): positive expiry time expected");
115 DeltaVolQuote::AtmType at;
116 DeltaVolQuote::DeltaType dt;
124 return QuantLib::ext::make_shared<VannaVolgaSmileSection>(spot, rd, rf, t, atm, rr, bf,
firstApprox_, at, dt,
delta_);
virtual QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm, Volatility rr, Volatility bf) const override
this must be implemented.
DeltaVolQuote::AtmType atmType_
FxBlackVolatilitySurface(const Date &referenceDate, const std::vector< Date > &dates, const std::vector< Volatility > &atmVols, const std::vector< Volatility > &rr, const std::vector< Volatility > &bf, const DayCounter &dayCounter, const Calendar &cal, const Handle< Quote > &fxSpot, const Handle< YieldTermStructure > &domesticTS, const Handle< YieldTermStructure > &foreignTS, bool requireMonotoneVariance=true, const DeltaVolQuote::AtmType atmType=DeltaVolQuote::AtmType::AtmDeltaNeutral, const DeltaVolQuote::DeltaType deltaType=DeltaVolQuote::DeltaType::Spot, const Real delta=0.25, const Period &switchTenor=0 *Days, const DeltaVolQuote::AtmType longTermAtmType=DeltaVolQuote::AtmType::AtmDeltaNeutral, const DeltaVolQuote::DeltaType longTermDeltaType=DeltaVolQuote::DeltaType::Spot)
virtual QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmileImpl(Real spot, Real rd, Real rf, Time t, Volatility atm, Volatility rr, Volatility bf) const =0
this must be implemented.
Handle< YieldTermStructure > foreignTS_
std::vector< Time > times_
BlackVarianceCurve atmCurve_
Handle< YieldTermStructure > domesticTS_
QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile(Time t) const
Return an FxSmile for the time t.
DeltaVolQuote::AtmType longTermAtmType_
virtual Volatility blackVolImpl(Time t, Real strike) const override
DeltaVolQuote::DeltaType deltaType_
std::vector< Volatility > bf_
DeltaVolQuote::DeltaType longTermDeltaType_
std::vector< Volatility > rr_
FX Black volatility surface that incorporates an FxSmile.
Filter close_enough(const RandomVariable &x, const RandomVariable &y)