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

capped floored overnight indexed coupon More...

#include <qle/cashflows/overnightindexedcoupon.hpp>

+ Inheritance diagram for CappedFlooredOvernightIndexedCoupon:
+ Collaboration diagram for CappedFlooredOvernightIndexedCoupon:

Public Member Functions

 CappedFlooredOvernightIndexedCoupon (const ext::shared_ptr< OvernightIndexedCoupon > &underlying, Real cap=Null< Real >(), Real floor=Null< Real >(), bool nakedOption=false, bool localCapFloor=false)
 
Observer interface
void deepUpdate () override
 
LazyObject interface
void performCalculations () const override
 
void alwaysForwardNotifications () override
 
Coupon interface
Rate rate () const override
 
Rate convexityAdjustment () const override
 
FloatingRateCoupon interface
Date fixingDate () const override
 
Rate cap () const
 cap More...
 
Rate floor () const
 floor More...
 
Rate effectiveCap () const
 effective cap of fixing More...
 
Rate effectiveFloor () const
 effective floor of fixing More...
 
Real effectiveCapletVolatility () const
 effective caplet volatility More...
 
Real effectiveFloorletVolatility () const
 effective floorlet volatility More...
 

Visitability

ext::shared_ptr< OvernightIndexedCouponunderlying_
 
Rate cap_
 
Rate floor_
 
bool nakedOption_
 
bool localCapFloor_
 
Real effectiveCapletVolatility_
 
Real effectiveFloorletVolatility_
 
virtual void accept (AcyclicVisitor &) override
 
bool isCapped () const
 
bool isFloored () const
 
ext::shared_ptr< OvernightIndexedCouponunderlying () const
 
bool nakedOption () const
 
bool localCapFloor () const
 

Detailed Description

capped floored overnight indexed coupon

Definition at line 152 of file overnightindexedcoupon.hpp.

Constructor & Destructor Documentation

◆ CappedFlooredOvernightIndexedCoupon()

CappedFlooredOvernightIndexedCoupon ( const ext::shared_ptr< OvernightIndexedCoupon > &  underlying,
Real  cap = Null<Real>(),
Real  floor = Null<Real>(),
bool  nakedOption = false,
bool  localCapFloor = false 
)

capped / floored compounded, backward-looking on coupon, local means that the daily rates are capped / floored while a global cap / floor is applied to the effective period rate

Definition at line 306 of file overnightindexedcoupon.cpp.

309 : FloatingRateCoupon(underlying->date(), underlying->nominal(), underlying->accrualStartDate(),
310 underlying->accrualEndDate(), underlying->fixingDays(), underlying->index(),
311 underlying->gearing(), underlying->spread(), underlying->referencePeriodStart(),
312 underlying->referencePeriodEnd(), underlying->dayCounter(), false),
314
315 QL_REQUIRE(!underlying_->includeSpread() || close_enough(underlying_->gearing(), 1.0),
316 "CappedFlooredOvernightIndexedCoupon: if include spread = true, only a gearing 1.0 is allowed - scale "
317 "the notional in this case instead.");
318
319 if (!localCapFloor) {
320 if (gearing_ > 0.0) {
321 cap_ = cap;
322 floor_ = floor;
323 } else {
324 cap_ = floor;
325 floor_ = cap;
326 }
327 } else {
328 cap_ = cap;
329 floor_ = floor;
330 }
331 if (cap_ != Null<Real>() && floor_ != Null<Real>()) {
332 QL_REQUIRE(cap_ >= floor, "cap level (" << cap_ << ") less than floor level (" << floor_ << ")");
333 }
334 registerWith(underlying_);
335 if (nakedOption_)
336 underlying_->alwaysForwardNotifications();
337}
ext::shared_ptr< OvernightIndexedCoupon > underlying() const
ext::shared_ptr< OvernightIndexedCoupon > underlying_
Filter close_enough(const RandomVariable &x, const RandomVariable &y)
+ Here is the call graph for this function:

Member Function Documentation

◆ deepUpdate()

void deepUpdate ( )
override

Definition at line 344 of file overnightindexedcoupon.cpp.

344 {
345 update();
346 underlying_->deepUpdate();
347}

◆ performCalculations()

void performCalculations ( ) const
override

Definition at line 349 of file overnightindexedcoupon.cpp.

349 {
350 QL_REQUIRE(underlying_->pricer(), "pricer not set");
351 Rate swapletRate = nakedOption_ ? 0.0 : underlying_->rate();
352 if (floor_ != Null<Real>() || cap_ != Null<Real>())
353 pricer()->initialize(*this);
354 Rate floorletRate = 0.;
355 if (floor_ != Null<Real>())
356 floorletRate = pricer()->floorletRate(effectiveFloor());
357 Rate capletRate = 0.;
358 if (cap_ != Null<Real>())
359 capletRate = (nakedOption_ && floor_ == Null<Real>() ? -1.0 : 1.0) * pricer()->capletRate(effectiveCap());
360 rate_ = swapletRate + floorletRate - capletRate;
361 auto p = QuantLib::ext::dynamic_pointer_cast<CappedFlooredOvernightIndexedCouponPricer>(pricer());
362 QL_REQUIRE(p, "CappedFlooredOvernightIndexedCoupon::performCalculations(): internal error, could not cast to "
363 "CappedFlooredOvernightIndexedCouponPricer");
364 effectiveCapletVolatility_ = p->effectiveCapletVolatility();
365 effectiveFloorletVolatility_ = p->effectiveFloorletVolatility();
366}
Rate effectiveCap() const
effective cap of fixing
Rate effectiveFloor() const
effective floor of fixing
+ Here is the call graph for this function:

◆ alwaysForwardNotifications()

void alwaysForwardNotifications ( )
override

Definition at line 339 of file overnightindexedcoupon.cpp.

339 {
340 LazyObject::alwaysForwardNotifications();
341 underlying_->alwaysForwardNotifications();
342}

◆ rate()

Rate rate ( ) const
override

Definition at line 372 of file overnightindexedcoupon.cpp.

372 {
373 calculate();
374 return rate_;
375}

◆ convexityAdjustment()

Rate convexityAdjustment ( ) const
override

Definition at line 377 of file overnightindexedcoupon.cpp.

377{ return underlying_->convexityAdjustment(); }

◆ fixingDate()

Date fixingDate ( ) const
override

Definition at line 176 of file overnightindexedcoupon.hpp.

176{ return underlying_->fixingDate(); }

◆ cap()

Rate cap ( ) const

cap

Definition at line 368 of file overnightindexedcoupon.cpp.

368{ return gearing_ > 0.0 ? cap_ : floor_; }
+ Here is the caller graph for this function:

◆ floor()

Rate floor ( ) const

floor

Definition at line 370 of file overnightindexedcoupon.cpp.

370{ return gearing_ > 0.0 ? floor_ : cap_; }
+ Here is the caller graph for this function:

◆ effectiveCap()

Rate effectiveCap ( ) const

effective cap of fixing

Definition at line 379 of file overnightindexedcoupon.cpp.

379 {
380 if (cap_ == Null<Real>())
381 return Null<Real>();
382 /* We have four cases dependent on localCapFloor_ and includeSpread. Notation in the formulas:
383 g gearing,
384 s spread,
385 A coupon amount,
386 f_i daily fixings,
387 \tau_i daily accrual fractions,
388 \tau coupon accrual fraction,
389 C cap rate
390 F floor rate
391 */
392 if (localCapFloor_) {
393 if (underlying_->includeSpread()) {
394 // A = g \cdot \frac{\prod (1 + \tau_i \min ( \max ( f_i + s , F), C)) - 1}{\tau}
395 return cap_ - underlying_->spread();
396 } else {
397 // A = g \cdot \frac{\prod (1 + \tau_i \min ( \max ( f_i , F), C)) - 1}{\tau} + s
398 return cap_;
399 }
400 } else {
401 if (underlying_->includeSpread()) {
402 // A = \min \left( \max \left( g \cdot \frac{\prod (1 + \tau_i(f_i + s)) - 1}{\tau}, F \right), C \right)
403 return (cap_ / gearing() - underlying_->effectiveSpread());
404 } else {
405 // A = \min \left( \max \left( g \cdot \frac{\prod (1 + \tau_i f_i) - 1}{\tau} + s, F \right), C \right)
406 return (cap_ - underlying_->effectiveSpread()) / gearing();
407 }
408 }
409}
+ Here is the caller graph for this function:

◆ effectiveFloor()

Rate effectiveFloor ( ) const

effective floor of fixing

Definition at line 411 of file overnightindexedcoupon.cpp.

411 {
412 if (floor_ == Null<Real>())
413 return Null<Real>();
414 if (localCapFloor_) {
415 if (underlying_->includeSpread()) {
416 return floor_ - underlying_->spread();
417 } else {
418 return floor_;
419 }
420 } else {
421 if (underlying_->includeSpread()) {
422 return (floor_ - underlying_->effectiveSpread());
423 } else {
424 return (floor_ - underlying_->effectiveSpread()) / gearing();
425 }
426 }
427}
+ Here is the caller graph for this function:

◆ effectiveCapletVolatility()

Real effectiveCapletVolatility ( ) const

effective caplet volatility

Definition at line 429 of file overnightindexedcoupon.cpp.

429 {
430 calculate();
432}

◆ effectiveFloorletVolatility()

Real effectiveFloorletVolatility ( ) const

effective floorlet volatility

Definition at line 434 of file overnightindexedcoupon.cpp.

434 {
435 calculate();
437}

◆ accept()

void accept ( AcyclicVisitor &  v)
overridevirtual

Definition at line 439 of file overnightindexedcoupon.cpp.

439 {
440 Visitor<CappedFlooredOvernightIndexedCoupon>* v1 = dynamic_cast<Visitor<CappedFlooredOvernightIndexedCoupon>*>(&v);
441 if (v1 != 0)
442 v1->visit(*this);
443 else
444 FloatingRateCoupon::accept(v);
445}

◆ isCapped()

bool isCapped ( ) const

Definition at line 195 of file overnightindexedcoupon.hpp.

195{ return cap_ != Null<Real>(); }

◆ isFloored()

bool isFloored ( ) const

Definition at line 196 of file overnightindexedcoupon.hpp.

196{ return floor_ != Null<Real>(); }

◆ underlying()

ext::shared_ptr< OvernightIndexedCoupon > underlying ( ) const

Definition at line 198 of file overnightindexedcoupon.hpp.

198{ return underlying_; }
+ Here is the caller graph for this function:

◆ nakedOption()

bool nakedOption ( ) const

Definition at line 199 of file overnightindexedcoupon.hpp.

199{ return nakedOption_; }

◆ localCapFloor()

bool localCapFloor ( ) const

Definition at line 200 of file overnightindexedcoupon.hpp.

200{ return localCapFloor_; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ underlying_

ext::shared_ptr<OvernightIndexedCoupon> underlying_
protected

Definition at line 203 of file overnightindexedcoupon.hpp.

◆ cap_

Rate cap_
protected

Definition at line 204 of file overnightindexedcoupon.hpp.

◆ floor_

Rate floor_
protected

Definition at line 204 of file overnightindexedcoupon.hpp.

◆ nakedOption_

bool nakedOption_
protected

Definition at line 205 of file overnightindexedcoupon.hpp.

◆ localCapFloor_

bool localCapFloor_
protected

Definition at line 206 of file overnightindexedcoupon.hpp.

◆ effectiveCapletVolatility_

Real effectiveCapletVolatility_
mutableprotected

Definition at line 207 of file overnightindexedcoupon.hpp.

◆ effectiveFloorletVolatility_

Real effectiveFloorletVolatility_
mutableprotected

Definition at line 208 of file overnightindexedcoupon.hpp.