Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FxBlackVolatilitySurface Class Referenceabstract

Fx Black volatility surface. More...

#include <qle/termstructures/fxblackvolsurface.hpp>

+ Inheritance diagram for FxBlackVolatilitySurface:
+ Collaboration diagram for FxBlackVolatilitySurface:

Public Member Functions

 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)
 
TermStructure interface
DayCounter dayCounter () const override
 
Date maxDate () const override
 
VolatilityTermStructure interface
Real minStrike () const override
 
Real maxStrike () const override
 

Visitability

std::vector< Time > times_
 
DayCounter dayCounter_
 
Handle< Quote > fxSpot_
 
Handle< YieldTermStructure > domesticTS_
 
Handle< YieldTermStructure > foreignTS_
 
BlackVarianceCurve atmCurve_
 
std::vector< Volatility > rr_
 
std::vector< Volatility > bf_
 
DeltaVolQuote::AtmType atmType_
 
DeltaVolQuote::DeltaType deltaType_
 
Real delta_
 
Period switchTenor_
 
DeltaVolQuote::AtmType longTermAtmType_
 
DeltaVolQuote::DeltaType longTermDeltaType_
 
Interpolation rrCurve_
 
Interpolation bfCurve_
 
Date maxDate_
 
virtual void accept (AcyclicVisitor &) override
 
QuantLib::ext::shared_ptr< FxSmileSectionblackVolSmile (Time t) const
 Return an FxSmile for the time t. More...
 
virtual Volatility blackVolImpl (Time t, Real strike) const override
 
virtual QuantLib::ext::shared_ptr< FxSmileSectionblackVolSmileImpl (Real spot, Real rd, Real rf, Time t, Volatility atm, Volatility rr, Volatility bf) const =0
 this must be implemented. More...
 

Detailed Description

Fx Black volatility surface.

This class calculates time/strike dependent Black volatilities

Definition at line 41 of file fxblackvolsurface.hpp.

Constructor & Destructor Documentation

◆ FxBlackVolatilitySurface()

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 
)

Definition at line 28 of file fxblackvolsurface.cpp.

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) {
40
41 QL_REQUIRE(dates.size() >= 1, "at least 1 date required");
42 maxDate_ = dates.back();
43
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");
46
47 // this has already been done for dates
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]);
51 if (i > 0) {
52 QL_REQUIRE(times_[i] > times_[i - 1], "dates must be sorted unique!");
53 }
54 }
55
56 // set up the 3 interpolators
57 if (dates.size() > 1) {
58 rrCurve_ = LinearInterpolation(times_.begin(), times_.end(), rr_.begin());
59 bfCurve_ = LinearInterpolation(times_.begin(), times_.end(), bf_.begin());
60 } else {
61 rrCurve_ = BackwardFlatInterpolation(times_.begin(), times_.end(), rr_.begin());
62 bfCurve_ = BackwardFlatInterpolation(times_.begin(), times_.end(), bf_.begin());
63 }
64
65 atmCurve_.enableExtrapolation();
66
67 registerWith(domesticTS_);
68 registerWith(foreignTS_);
69 registerWith(fxSpot_);
70}
Handle< YieldTermStructure > foreignTS_
Handle< YieldTermStructure > domesticTS_
DayCounter dayCounter() const override
DeltaVolQuote::AtmType longTermAtmType_
DeltaVolQuote::DeltaType deltaType_
DeltaVolQuote::DeltaType longTermDeltaType_

Member Function Documentation

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Definition at line 56 of file fxblackvolsurface.hpp.

56{ return dayCounter_; }

◆ maxDate()

Date maxDate ( ) const
override

Definition at line 57 of file fxblackvolsurface.hpp.

57{ return maxDate_; }

◆ minStrike()

Real minStrike ( ) const
override

Definition at line 61 of file fxblackvolsurface.hpp.

61{ return 0; } // we allow 0 for ATM vols

◆ maxStrike()

Real maxStrike ( ) const
override

Definition at line 62 of file fxblackvolsurface.hpp.

62{ return QL_MAX_REAL; }

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 101 of file fxblackvolsurface.hpp.

101 {
102 Visitor<FxBlackVolatilitySurface>* v1 = dynamic_cast<Visitor<FxBlackVolatilitySurface>*>(&v);
103 if (v1 != 0)
104 v1->visit(*this);
105 else
106 BlackVolatilityTermStructure::accept(v);
107}

◆ blackVolSmile()

QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile ( Time  t) const

Return an FxSmile for the time t.

Note the smile does not observe the spot or YTS handles, it will not update when they change

Definition at line 72 of file fxblackvolsurface.cpp.

72 {
73 // we interpolate on the 3 curves independently
74 Volatility atm = atmCurve_.blackVol(t, 0); // blackVol returns atm vol when strike is 0
75
76 // Flat extrapolation for RR + BF.
77 Volatility rr, bf;
78 if (t < times_.front()) {
79 // flat RR + BF
80 rr = rrCurve_(times_.front());
81 bf = bfCurve_(times_.front());
82
83 // we account cases where the FxSmileSection requires t > 0 by using the first pillar point
84 QL_REQUIRE(t >= 0, "FxBlackVolatilitySurface::blackVolSmileImpl(): non-negative expiry time expected");
85 t = times_.front();
86 } else if (t < times_.back()) {
87 rr = rrCurve_(t, true);
88 bf = bfCurve_(t, true);
89 } else {
90 // flat RR + BF
91 rr = rrCurve_(times_.back());
92 bf = bfCurve_(times_.back());
93 }
94
95 Real rd = domesticTS_->zeroRate(t, Continuous);
96 Real rf = foreignTS_->zeroRate(t, Continuous);
97
98 return blackVolSmileImpl(fxSpot_->value(), rd, rf, t, atm, rr, bf);
99}
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.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ blackVolImpl()

Volatility blackVolImpl ( Time  t,
Real  strike 
) const
overrideprotectedvirtual

Definition at line 101 of file fxblackvolsurface.cpp.

101 {
102 // If asked for strike == 0, just return the ATM value.
103 if (strike == 0 || strike == Null<Real>())
104 return atmCurve_.blackVol(t, 0);
105 else
106 return blackVolSmile(t)->volatility(strike);
107}
QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmile(Time t) const
Return an FxSmile for the time t.
+ Here is the call graph for this function:

◆ blackVolSmileImpl()

virtual QuantLib::ext::shared_ptr< FxSmileSection > blackVolSmileImpl ( Real  spot,
Real  rd,
Real  rf,
Time  t,
Volatility  atm,
Volatility  rr,
Volatility  bf 
) const
protectedpure virtual

this must be implemented.

Implemented in FxBlackVannaVolgaVolatilitySurface.

+ Here is the caller graph for this function:

Member Data Documentation

◆ times_

std::vector<Time> times_
protected

Definition at line 81 of file fxblackvolsurface.hpp.

◆ dayCounter_

DayCounter dayCounter_
protected

Definition at line 82 of file fxblackvolsurface.hpp.

◆ fxSpot_

Handle<Quote> fxSpot_
protected

Definition at line 83 of file fxblackvolsurface.hpp.

◆ domesticTS_

Handle<YieldTermStructure> domesticTS_
protected

Definition at line 84 of file fxblackvolsurface.hpp.

◆ foreignTS_

Handle<YieldTermStructure> foreignTS_
protected

Definition at line 85 of file fxblackvolsurface.hpp.

◆ atmCurve_

BlackVarianceCurve atmCurve_
protected

Definition at line 86 of file fxblackvolsurface.hpp.

◆ rr_

std::vector<Volatility> rr_
protected

Definition at line 87 of file fxblackvolsurface.hpp.

◆ bf_

std::vector<Volatility> bf_
protected

Definition at line 88 of file fxblackvolsurface.hpp.

◆ atmType_

DeltaVolQuote::AtmType atmType_
protected

Definition at line 89 of file fxblackvolsurface.hpp.

◆ deltaType_

DeltaVolQuote::DeltaType deltaType_
protected

Definition at line 90 of file fxblackvolsurface.hpp.

◆ delta_

Real delta_
protected

Definition at line 91 of file fxblackvolsurface.hpp.

◆ switchTenor_

Period switchTenor_
protected

Definition at line 92 of file fxblackvolsurface.hpp.

◆ longTermAtmType_

DeltaVolQuote::AtmType longTermAtmType_
protected

Definition at line 93 of file fxblackvolsurface.hpp.

◆ longTermDeltaType_

DeltaVolQuote::DeltaType longTermDeltaType_
protected

Definition at line 94 of file fxblackvolsurface.hpp.

◆ rrCurve_

Interpolation rrCurve_
protected

Definition at line 95 of file fxblackvolsurface.hpp.

◆ bfCurve_

Interpolation bfCurve_
protected

Definition at line 96 of file fxblackvolsurface.hpp.

◆ maxDate_

Date maxDate_
protected

Definition at line 97 of file fxblackvolsurface.hpp.