30#ifndef quantlib_pricers_black_swaption_hpp
31#define quantlib_pricers_black_swaption_hpp
60 Real displacement = 0.0,
65 Real displacement = 0.0,
84 const Real atmForward,
const Real stdDev,
const Real annuity,
85 const Real displacement) {
90 const Real exerciseTime,
const Real annuity,
91 const Real displacement) {
92 return std::sqrt(exerciseTime) *
94 annuity, displacement);
97 const Real atmForward,
const Real stdDev,
const Real annuity,
98 const Real displacement) {
100 annuity, displacement);
108 const Real atmForward,
const Real stdDev,
const Real annuity,
114 const Real exerciseTime,
const Real annuity,
const Real) {
115 return std::sqrt(exerciseTime) *
117 strike, atmForward, stdDev, annuity);
120 const Real atmForward,
const Real stdDev,
const Real annuity,
123 type, strike, atmForward, stdDev, annuity);
142 Real displacement = 0.0,
147 Real displacement = 0.0,
181 template <
class Spec>
195 template <
class Spec>
210 template <
class Spec>
222 static const Spread basisPoint = 1.0e-4;
224 Date exerciseDate = arguments_.exercise->date(0);
230 auto swap = arguments_.swap;
232 const Leg& fixedLeg =
swap->fixedLeg();
233 ext::shared_ptr<FixedRateCoupon> firstCoupon =
234 ext::dynamic_pointer_cast<FixedRateCoupon>(fixedLeg[0]);
235 QL_REQUIRE(firstCoupon->accrualStartDate() >= exerciseDate,
236 "swap start (" << firstCoupon->accrualStartDate() <<
") before exercise date ("
237 << exerciseDate <<
") not supported in Black swaption engine");
243 auto engine = ext::make_shared<DiscountingSwapEngine>(
discountCurve_,
false);
245 swap->setPricingEngine(engine);
256 spread * std::fabs(
swap->floatingLegBPS() /
swap->fixedLegBPS());
257 strike -= correction;
258 atmForward -= correction;
259 results_.additionalResults[
"spreadCorrection"] = correction;
261 results_.additionalResults[
"spreadCorrection"] =
Real(0.0);
263 results_.additionalResults[
"strike"] = strike;
264 results_.additionalResults[
"atmForward"] = atmForward;
269 arguments_.settlementMethod ==
271 annuity = std::fabs(
swap->fixedLegBPS()) / basisPoint;
274 DayCounter dayCount = firstCoupon->dayCounter();
278 ? firstCoupon->accrualStartDate()
285 Real fixedLegCashBPS =
288 false, discountDate);
289 annuity = std::fabs(fixedLegCashBPS / basisPoint) *
292 QL_FAIL(
"invalid (settlementType, settlementMethod) pair");
294 results_.additionalResults[
"annuity"] = annuity;
296 const Schedule& floatingSchedule =
swap->floatingSchedule();
297 Time swapLength =
vol_->swapLength(floatingSchedule.
dates().front(),
298 floatingSchedule.
dates().back());
302 swapLength = std::max(swapLength, 1.0 / 12.0);
303 results_.additionalResults[
"swapLength"] = swapLength;
309 vol_->shift(exerciseDate, swapLength) : 0.0;
312 results_.additionalResults[
"stdDev"] = stdDev;
314 results_.value = Spec().value(w, strike, atmForward, stdDev, annuity, displacement);
316 Time exerciseTime =
vol_->timeFromReference(exerciseDate);
317 results_.additionalResults[
"vega"] = Spec().vega(
318 strike, atmForward, stdDev, exerciseTime, annuity, displacement);
319 results_.additionalResults[
"delta"] = Spec().delta(
320 w, strike, atmForward, stdDev, annuity, displacement);
321 results_.additionalResults[
"timeToExpiry"] = exerciseTime;
322 results_.additionalResults[
"impliedVolatility"] =
Real(stdDev / std::sqrt(exerciseTime));
const YieldTermStructure & discountCurve_
Cash-flow analysis functions.
ext::shared_ptr< SimpleQuote > vol_
const Instrument::results * results_
Actual/365 (Fixed) day count convention.
Normal Bachelier-formula swaption engine.
Shifted Lognormal Black-formula swaption engine.
static Real bps(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date())
Basis-point sensitivity of the cash flows.
Constant swaption volatility, no time-strike dependence.
Shared handle to an observable.
Concrete interest rate class.
YieldTermStructure based on interpolation of discount factors.
Calendar for reproducing theoretical calculations.
void disableUpdates(bool deferred=false)
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Frequency frequency() const
const std::vector< Date > & dates() const
const Period & tenor() const
static ObservableSettings & instance()
access to the unique instance
base class for swaption engines
Swaption-volatility structure
Handle< YieldTermStructure > discountCurve_
BlackStyleSwaptionEngine(Handle< YieldTermStructure > discountCurve, Volatility vol, const DayCounter &dc=Actual365Fixed(), Real displacement=0.0, CashAnnuityModel model=DiscountCurve)
Handle< SwaptionVolatilityStructure > volatility()
BlackStyleSwaptionEngine(Handle< YieldTermStructure > discountCurve, const Handle< Quote > &vol, const DayCounter &dc=Actual365Fixed(), Real displacement=0.0, CashAnnuityModel model=DiscountCurve)
BlackStyleSwaptionEngine(Handle< YieldTermStructure > discountCurve, Handle< SwaptionVolatilityStructure > vol, CashAnnuityModel model=DiscountCurve)
void calculate() const override
Handle< SwaptionVolatilityStructure > vol_
Handle< YieldTermStructure > termStructure()
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Option exercise classes and payoff function.
LinearInterpolation variance
Coupon paying a fixed annual rate.
Frequency
Frequency of events.
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
Real Spread
spreads on interest rates
base class for Inter-Bank-Offered-Rate indexes
Real bachelierBlackFormulaStdDevDerivative(Rate strike, Rate forward, Real stdDev, Real discount)
Real bachelierBlackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount)
void swap(Array &v, Array &w) noexcept
Real blackFormulaForwardDerivative(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
Real bachelierBlackFormulaForwardDerivative(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount)
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)
Real blackFormulaStdDevDerivative(Rate strike, Rate forward, Real stdDev, Real discount, Real displacement)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Calendar for reproducing theoretical calculations.
@ CollateralizedCashPrice
Real vega(const Real strike, const Real atmForward, const Real stdDev, const Real exerciseTime, const Real annuity, const Real)
Real value(const Option::Type type, const Real strike, const Real atmForward, const Real stdDev, const Real annuity, const Real)
Real delta(const Option::Type type, const Real strike, const Real atmForward, const Real stdDev, const Real annuity, const Real)
static const VolatilityType type
Real value(const Option::Type type, const Real strike, const Real atmForward, const Real stdDev, const Real annuity, const Real displacement)
Real vega(const Real strike, const Real atmForward, const Real stdDev, const Real exerciseTime, const Real annuity, const Real displacement)
static const VolatilityType type
Real delta(const Option::Type type, const Real strike, const Real atmForward, const Real stdDev, const Real annuity, const Real displacement)
Constant swaption volatility.
Swaption volatility structure.