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

#include <qle/models/linearannuitymapping.hpp>

+ Inheritance diagram for LinearAnnuityMappingBuilder:
+ Collaboration diagram for LinearAnnuityMappingBuilder:

Public Member Functions

 LinearAnnuityMappingBuilder (const Real a, const Real b)
 
 LinearAnnuityMappingBuilder (const Handle< Quote > &reversion)
 
QuantLib::ext::shared_ptr< AnnuityMappingbuild (const Date &valuationDate, const Date &optionDate, const Date &paymentDate, const VanillaSwap &underlying, const Handle< YieldTermStructure > &discountCurve) override
 
- Public Member Functions inherited from AnnuityMappingBuilder
virtual ~AnnuityMappingBuilder ()
 
virtual QuantLib::ext::shared_ptr< AnnuityMappingbuild (const Date &valuationDate, const Date &optionDate, const Date &paymentDate, const VanillaSwap &underlying, const Handle< YieldTermStructure > &discountCurve)=0
 
void update () override
 

Private Attributes

Real a_ = Null<Real>()
 
Real b_ = Null<Real>()
 
Handle< Quote > reversion_
 

Detailed Description

linear annuity mapping builder

Definition at line 47 of file linearannuitymapping.hpp.

Constructor & Destructor Documentation

◆ LinearAnnuityMappingBuilder() [1/2]

LinearAnnuityMappingBuilder ( const Real  a,
const Real  b 
)

◆ LinearAnnuityMappingBuilder() [2/2]

LinearAnnuityMappingBuilder ( const Handle< Quote > &  reversion)

Definition at line 40 of file linearannuitymapping.cpp.

40 : reversion_(reversion) {
41 registerWith(reversion_);
42}

Member Function Documentation

◆ build()

QuantLib::ext::shared_ptr< AnnuityMapping > build ( const Date &  valuationDate,
const Date &  optionDate,
const Date &  paymentDate,
const VanillaSwap &  underlying,
const Handle< YieldTermStructure > &  discountCurve 
)
overridevirtual

Implements AnnuityMappingBuilder.

Definition at line 53 of file linearannuitymapping.cpp.

56 {
57
58 // no need for an actual mapping, since the coupon amount is deterministic, i.e. model-independent
59
60 if (optionDate <= valuationDate)
61 return QuantLib::ext::make_shared<LinearAnnuityMapping>(0.0, 0.0);
62
63 // build the mapping dependent on whether a, b or a reversion is given
64
65 if (a_ != Null<Real>() && b_ != Null<Real>()) {
66 return QuantLib::ext::make_shared<LinearAnnuityMapping>(a_, b_);
67 } else if (!reversion_.empty()) {
68 Real atmForward = underlying.fairRate();
69 Real gx = 0.0, gy = 0.0;
70 for (Size i = 0; i < underlying.fixedLeg().size(); i++) {
71 QuantLib::ext::shared_ptr<Coupon> c = QuantLib::ext::dynamic_pointer_cast<Coupon>(underlying.fixedLeg()[i]);
72 Real yf = c->accrualPeriod();
73 Real pv = yf * discountCurve->discount(c->date());
74 gx += pv * GsrG(discountCurve->dayCounter().yearFraction(optionDate, c->date()), reversion_->value());
75 gy += pv;
76 }
77 Real gamma = gx / gy;
78 Date lastd = underlying.fixedLeg().back()->date();
79 Real a =
80 discountCurve->discount(paymentDate) *
81 (gamma - GsrG(discountCurve->dayCounter().yearFraction(optionDate, paymentDate), reversion_->value())) /
82 (discountCurve->discount(lastd) *
83 GsrG(discountCurve->dayCounter().yearFraction(optionDate, lastd), reversion_->value()) +
84 atmForward * gy * gamma);
85 Real b = discountCurve->discount(paymentDate) / gy - a * atmForward;
86 return QuantLib::ext::make_shared<LinearAnnuityMapping>(a, b);
87 } else {
88 QL_FAIL("LinearAnnuityMapping::build(): failed, because neither a, b nor a reversion is given");
89 }
90}

Member Data Documentation

◆ a_

Real a_ = Null<Real>()
private

Definition at line 56 of file linearannuitymapping.hpp.

◆ b_

Real b_ = Null<Real>()
private

Definition at line 56 of file linearannuitymapping.hpp.

◆ reversion_

Handle<Quote> reversion_
private

Definition at line 57 of file linearannuitymapping.hpp.