QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SwaptionHelper Class Reference

calibration helper for interest-rate swaptions More...

#include <swaptionhelper.hpp>

+ Inheritance diagram for SwaptionHelper:
+ Collaboration diagram for SwaptionHelper:

Public Member Functions

 SwaptionHelper (const Period &maturity, const Period &length, const Handle< Quote > &volatility, ext::shared_ptr< IborIndex > index, const Period &fixedLegTenor, DayCounter fixedLegDayCounter, DayCounter floatingLegDayCounter, Handle< YieldTermStructure > termStructure, CalibrationErrorType errorType=RelativePriceError, Real strike=Null< Real >(), Real nominal=1.0, VolatilityType type=ShiftedLognormal, Real shift=0.0, Natural settlementDays=Null< Size >(), RateAveraging::Type averagingMethod=RateAveraging::Compound)
 
 SwaptionHelper (const Date &exerciseDate, const Period &length, const Handle< Quote > &volatility, ext::shared_ptr< IborIndex > index, const Period &fixedLegTenor, DayCounter fixedLegDayCounter, DayCounter floatingLegDayCounter, Handle< YieldTermStructure > termStructure, CalibrationErrorType errorType=RelativePriceError, Real strike=Null< Real >(), Real nominal=1.0, VolatilityType type=ShiftedLognormal, Real shift=0.0, Natural settlementDays=Null< Size >(), RateAveraging::Type averagingMethod=RateAveraging::Compound)
 
 SwaptionHelper (const Date &exerciseDate, const Date &endDate, const Handle< Quote > &volatility, ext::shared_ptr< IborIndex > index, const Period &fixedLegTenor, DayCounter fixedLegDayCounter, DayCounter floatingLegDayCounter, Handle< YieldTermStructure > termStructure, CalibrationErrorType errorType=RelativePriceError, Real strike=Null< Real >(), Real nominal=1.0, VolatilityType type=ShiftedLognormal, Real shift=0.0, Natural settlementDays=Null< Size >(), RateAveraging::Type averagingMethod=RateAveraging::Compound)
 
void addTimesTo (std::list< Time > &times) const override
 
Real modelValue () const override
 returns the price of the instrument according to the model More...
 
Real blackPrice (Volatility volatility) const override
 Black or Bachelier price given a volatility. More...
 
const ext::shared_ptr< FixedVsFloatingSwap > & underlying () const
 
ext::shared_ptr< VanillaSwapunderlyingSwap () const
 
ext::shared_ptr< Swaptionswaption () const
 
- Public Member Functions inherited from BlackCalibrationHelper
 BlackCalibrationHelper (Handle< Quote > volatility, CalibrationErrorType calibrationErrorType=RelativePriceError, const VolatilityType type=ShiftedLognormal, const Real shift=0.0)
 
void performCalculations () const override
 
Handle< Quotevolatility () const
 returns the volatility Handle More...
 
VolatilityType volatilityType () const
 returns the volatility type More...
 
Real marketValue () const
 returns the actual price of the instrument (from volatility) More...
 
virtual Real modelValue () const =0
 returns the price of the instrument according to the model More...
 
Real calibrationError () override
 returns the error resulting from the model valuation More...
 
virtual void addTimesTo (std::list< Time > &times) const =0
 
Volatility impliedVolatility (Real targetValue, Real accuracy, Size maxEvaluations, Volatility minVol, Volatility maxVol) const
 Black volatility implied by the model. More...
 
virtual Real blackPrice (Volatility volatility) const =0
 Black or Bachelier price given a volatility. More...
 
void setPricingEngine (const ext::shared_ptr< PricingEngine > &engine)
 
- Public Member Functions inherited from LazyObject
 LazyObject ()
 
 ~LazyObject () override=default
 
void update () override
 
bool isCalculated () const
 
void forwardFirstNotificationOnly ()
 
void alwaysForwardNotifications ()
 
void recalculate ()
 
void freeze ()
 
void unfreeze ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 
- Public Member Functions inherited from CalibrationHelper
virtual ~CalibrationHelper ()=default
 
virtual Real calibrationError ()=0
 returns the error resulting from the model valuation More...
 

Private Member Functions

void performCalculations () const override
 
ext::shared_ptr< FixedVsFloatingSwapmakeSwap (Schedule fixedSchedule, Schedule floatSchedule, Rate exerciseRate, Swap::Type type) const
 

Private Attributes

Date exerciseDate_
 
Date endDate_
 
const Period maturity_
 
const Period length_
 
const Period fixedLegTenor_
 
const ext::shared_ptr< IborIndexindex_
 
const Handle< YieldTermStructuretermStructure_
 
const DayCounter fixedLegDayCounter_
 
const DayCounter floatingLegDayCounter_
 
const Real strike_
 
const Real nominal_
 
const Natural settlementDays_
 
const RateAveraging::Type averagingMethod_
 
Rate exerciseRate_
 
ext::shared_ptr< FixedVsFloatingSwapswap_
 
ext::shared_ptr< Swaptionswaption_
 

Additional Inherited Members

- Public Types inherited from BlackCalibrationHelper
enum  CalibrationErrorType { RelativePriceError , PriceError , ImpliedVolError }
 
- Public Types inherited from Observer
typedef set_type::iterator iterator
 
- Protected Member Functions inherited from LazyObject
virtual void calculate () const
 
- Protected Attributes inherited from BlackCalibrationHelper
Real marketValue_
 
Handle< Quotevolatility_
 
ext::shared_ptr< PricingEngineengine_
 
const VolatilityType volatilityType_
 
const Real shift_
 
- Protected Attributes inherited from LazyObject
bool calculated_ = false
 
bool frozen_ = false
 
bool alwaysForward_
 

Detailed Description

calibration helper for interest-rate swaptions

Warning:
passing an overnight index to the constructor will result in an overnight-indexed swap being built, but model-based engines will treat it as a vanilla swap. This is at best a decent proxy, at worst simply wrong. Use with caution.

Definition at line 42 of file swaptionhelper.hpp.

Constructor & Destructor Documentation

◆ SwaptionHelper() [1/3]

SwaptionHelper ( const Period maturity,
const Period length,
const Handle< Quote > &  volatility,
ext::shared_ptr< IborIndex index,
const Period fixedLegTenor,
DayCounter  fixedLegDayCounter,
DayCounter  floatingLegDayCounter,
Handle< YieldTermStructure termStructure,
CalibrationErrorType  errorType = RelativePriceError,
Real  strike = Null<Real>(),
Real  nominal = 1.0,
VolatilityType  type = ShiftedLognormal,
Real  shift = 0.0,
Natural  settlementDays = Null<Size>(),
RateAveraging::Type  averagingMethod = RateAveraging::Compound 
)

Definition at line 35 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ SwaptionHelper() [2/3]

SwaptionHelper ( const Date exerciseDate,
const Period length,
const Handle< Quote > &  volatility,
ext::shared_ptr< IborIndex index,
const Period fixedLegTenor,
DayCounter  fixedLegDayCounter,
DayCounter  floatingLegDayCounter,
Handle< YieldTermStructure termStructure,
CalibrationErrorType  errorType = RelativePriceError,
Real  strike = Null<Real>(),
Real  nominal = 1.0,
VolatilityType  type = ShiftedLognormal,
Real  shift = 0.0,
Natural  settlementDays = Null<Size>(),
RateAveraging::Type  averagingMethod = RateAveraging::Compound 
)

Definition at line 60 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ SwaptionHelper() [3/3]

SwaptionHelper ( const Date exerciseDate,
const Date endDate,
const Handle< Quote > &  volatility,
ext::shared_ptr< IborIndex index,
const Period fixedLegTenor,
DayCounter  fixedLegDayCounter,
DayCounter  floatingLegDayCounter,
Handle< YieldTermStructure termStructure,
CalibrationErrorType  errorType = RelativePriceError,
Real  strike = Null<Real>(),
Real  nominal = 1.0,
VolatilityType  type = ShiftedLognormal,
Real  shift = 0.0,
Natural  settlementDays = Null<Size>(),
RateAveraging::Type  averagingMethod = RateAveraging::Compound 
)

Definition at line 85 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

Member Function Documentation

◆ addTimesTo()

void addTimesTo ( std::list< Time > &  times) const
overridevirtual

Implements BlackCalibrationHelper.

Definition at line 111 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ modelValue()

Real modelValue ( ) const
overridevirtual

returns the price of the instrument according to the model

Implements BlackCalibrationHelper.

Definition at line 123 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ blackPrice()

Real blackPrice ( Volatility  volatility) const
overridevirtual

Black or Bachelier price given a volatility.

Implements BlackCalibrationHelper.

Definition at line 129 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ underlying()

const ext::shared_ptr< FixedVsFloatingSwap > & underlying ( ) const

Definition at line 96 of file swaptionhelper.hpp.

+ Here is the call graph for this function:

◆ underlyingSwap()

ext::shared_ptr< VanillaSwap > underlyingSwap ( ) const
Deprecated:
Use the SwaptionHelper::underlying method instead. Deprecated in version 1.34.

Definition at line 104 of file swaptionhelper.hpp.

+ Here is the call graph for this function:

◆ swaption()

ext::shared_ptr< Swaption > swaption ( ) const

Definition at line 110 of file swaptionhelper.hpp.

+ Here is the call graph for this function:

◆ performCalculations()

void performCalculations ( ) const
overrideprivatevirtual

This method must implement any calculations which must be (re)done in order to calculate the desired results.

Reimplemented from BlackCalibrationHelper.

Definition at line 152 of file swaptionhelper.cpp.

+ Here is the call graph for this function:

◆ makeSwap()

ext::shared_ptr< FixedVsFloatingSwap > makeSwap ( Schedule  fixedSchedule,
Schedule  floatSchedule,
Rate  exerciseRate,
Swap::Type  type 
) const
private

Definition at line 201 of file swaptionhelper.cpp.

+ Here is the caller graph for this function:

Member Data Documentation

◆ exerciseDate_

Date exerciseDate_
mutableprivate

Definition at line 118 of file swaptionhelper.hpp.

◆ endDate_

Date endDate_
private

Definition at line 118 of file swaptionhelper.hpp.

◆ maturity_

const Period maturity_
private

Definition at line 119 of file swaptionhelper.hpp.

◆ length_

const Period length_
private

Definition at line 119 of file swaptionhelper.hpp.

◆ fixedLegTenor_

const Period fixedLegTenor_
private

Definition at line 119 of file swaptionhelper.hpp.

◆ index_

const ext::shared_ptr<IborIndex> index_
private

Definition at line 120 of file swaptionhelper.hpp.

◆ termStructure_

const Handle<YieldTermStructure> termStructure_
private

Definition at line 121 of file swaptionhelper.hpp.

◆ fixedLegDayCounter_

const DayCounter fixedLegDayCounter_
private

Definition at line 122 of file swaptionhelper.hpp.

◆ floatingLegDayCounter_

const DayCounter floatingLegDayCounter_
private

Definition at line 122 of file swaptionhelper.hpp.

◆ strike_

const Real strike_
private

Definition at line 123 of file swaptionhelper.hpp.

◆ nominal_

const Real nominal_
private

Definition at line 123 of file swaptionhelper.hpp.

◆ settlementDays_

const Natural settlementDays_
private

Definition at line 124 of file swaptionhelper.hpp.

◆ averagingMethod_

const RateAveraging::Type averagingMethod_
private

Definition at line 125 of file swaptionhelper.hpp.

◆ exerciseRate_

Rate exerciseRate_
mutableprivate

Definition at line 126 of file swaptionhelper.hpp.

◆ swap_

ext::shared_ptr<FixedVsFloatingSwap> swap_
mutableprivate

Definition at line 127 of file swaptionhelper.hpp.

◆ swaption_

ext::shared_ptr<Swaption> swaption_
mutableprivate

Definition at line 128 of file swaptionhelper.hpp.