Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
List of all members
BRLCdiCouponPricer Class Reference

BRL CDI coupon pricer. More...

#include <qle/cashflows/brlcdicouponpricer.hpp>

+ Inheritance diagram for BRLCdiCouponPricer:
+ Collaboration diagram for BRLCdiCouponPricer:

FloatingRateCouponPricer interface

const QuantLib::OvernightIndexedCoupon * couponQl_
 
const QuantExt::OvernightIndexedCouponcouponQle_
 
QuantLib::ext::shared_ptr< BRLCdiindex_
 The index underlying the coupon to be priced. More...
 
virtual QuantLib::Rate swapletRate () const override
 
virtual void initialize (const QuantLib::FloatingRateCoupon &coupon) override
 
virtual QuantLib::Real swapletPrice () const override
 
virtual QuantLib::Real capletPrice (QuantLib::Rate effectiveCap) const override
 
virtual QuantLib::Rate capletRate (QuantLib::Rate effectiveCap) const override
 
virtual QuantLib::Real floorletPrice (QuantLib::Rate effectiveFloor) const override
 
virtual QuantLib::Rate floorletRate (QuantLib::Rate effectiveFloor) const override
 

Detailed Description

BRL CDI coupon pricer.

Definition at line 36 of file brlcdicouponpricer.hpp.

Member Function Documentation

◆ swapletRate()

Rate swapletRate ( ) const
overridevirtual

Definition at line 30 of file brlcdicouponpricer.cpp.

30 {
31
32 const vector<Date>& fixingDates = couponQl_ ? couponQl_->fixingDates() : couponQle_->fixingDates();
33 const vector<Time>& dt = couponQl_ ? couponQl_->dt() : couponQle_->dt();
34 Size n = dt.size();
35 Size i = 0;
36 Real compoundFactor = 1.0;
37 Date today = Settings::instance().evaluationDate();
38
39 // Already fixed part of the coupon
40 while (i < n && fixingDates[i] < today) {
41 Rate pastFixing = IndexManager::instance().getHistory(index_->name())[fixingDates[i]];
42 QL_REQUIRE(pastFixing != Null<Real>(), "Missing " << index_->name() << " fixing for " << fixingDates[i]);
43 compoundFactor *= pow(1.0 + pastFixing, dt[i]);
44 ++i;
45 }
46
47 // Today is a border case. If there is a fixing use it. If not, it will be projected in the next block.
48 if (i < n && fixingDates[i] == today) {
49 try {
50 Rate pastFixing = IndexManager::instance().getHistory(index_->name())[fixingDates[i]];
51 if (pastFixing != Null<Real>()) {
52 compoundFactor *= pow(1.0 + pastFixing, dt[i]);
53 ++i;
54 }
55 } catch (Error&) {
56 }
57 }
58
59 // Use telescopic property for piece of coupon in the future
60 // \Pi_{i=0}^{n-1} \left( 1 + DI(t, t_{i}, t_{i+1}) \right) ^ \delta = \frac{P(t, t_0)}{P(t, t_n)}
61 if (i < n) {
62 Handle<YieldTermStructure> curve = index_->forwardingTermStructure();
63 QL_REQUIRE(!curve.empty(), "BRLCdiCouponPricer needs the index to have a forwarding term structure");
64
65 const vector<Date>& dates = couponQl_ ? couponQl_->valueDates() : couponQle_->valueDates();
66 DiscountFactor startDiscount = curve->discount(dates[i]);
67 DiscountFactor endDiscount = curve->discount(dates[n]);
68
69 compoundFactor *= startDiscount / endDiscount;
70 }
71
72 Rate rate = (compoundFactor - 1.0) / (couponQl_ ? couponQl_->accrualPeriod() : couponQle_->accrualPeriod());
73 return (couponQl_ ? couponQl_->gearing() : couponQle_->gearing()) * rate +
74 (couponQl_ ? couponQl_->spread() : couponQle_->spread());
75}
QuantLib::ext::shared_ptr< BRLCdi > index_
The index underlying the coupon to be priced.
const QuantExt::OvernightIndexedCoupon * couponQle_
const QuantLib::OvernightIndexedCoupon * couponQl_
const std::vector< Date > & valueDates() const
value dates for the rates to be compounded
const std::vector< Time > & dt() const
accrual (compounding) periods
const std::vector< Date > & fixingDates() const
fixing dates for the rates to be compounded
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)
+ Here is the call graph for this function:

◆ initialize()

void initialize ( const QuantLib::FloatingRateCoupon &  coupon)
overridevirtual

Definition at line 77 of file brlcdicouponpricer.cpp.

77 {
78 // Ensure that we have an overnight coupon and that the index is BRL DI
79 couponQl_ = dynamic_cast<const QuantLib::OvernightIndexedCoupon*>(&coupon);
80 couponQle_ = dynamic_cast<const QuantExt::OvernightIndexedCoupon*>(&coupon);
81 QL_REQUIRE(couponQl_ || couponQle_, "BRLCdiCouponPricer expects an OvernightIndexedCoupon");
82
83 QuantLib::ext::shared_ptr<InterestRateIndex> index = couponQl_ ? couponQl_->index() : couponQle_->index();
84 index_ = QuantLib::ext::dynamic_pointer_cast<BRLCdi>(index);
85 QL_REQUIRE(index_, "BRLCdiCouponPricer expects the coupon's index to be BRLCdi");
86}

◆ swapletPrice()

Real swapletPrice ( ) const
overridevirtual

Definition at line 88 of file brlcdicouponpricer.cpp.

88{ QL_FAIL("swapletPrice not implemented for BRLCdiCouponPricer"); }

◆ capletPrice()

Real capletPrice ( QuantLib::Rate  effectiveCap) const
overridevirtual

Definition at line 90 of file brlcdicouponpricer.cpp.

90 {
91 QL_FAIL("capletPrice not implemented for BRLCdiCouponPricer");
92}

◆ capletRate()

Real capletRate ( QuantLib::Rate  effectiveCap) const
overridevirtual

Definition at line 94 of file brlcdicouponpricer.cpp.

94 {
95 QL_FAIL("capletRate not implemented for BRLCdiCouponPricer");
96}

◆ floorletPrice()

Real floorletPrice ( QuantLib::Rate  effectiveFloor) const
overridevirtual

Definition at line 98 of file brlcdicouponpricer.cpp.

98 {
99 QL_FAIL("floorletPrice not implemented for BRLCdiCouponPricer");
100}

◆ floorletRate()

Real floorletRate ( QuantLib::Rate  effectiveFloor) const
overridevirtual

Definition at line 102 of file brlcdicouponpricer.cpp.

102 {
103 QL_FAIL("floorletRate not implemented for BRLCdiCouponPricer");
104}

Member Data Documentation

◆ couponQl_

const QuantLib::OvernightIndexedCoupon* couponQl_
private

The coupon to be priced, for now we support both QuantLib::OvernightIndexedCoupon and QuantExt::OvernightIndexedCoupon, see ORE ticket 1159

Definition at line 53 of file brlcdicouponpricer.hpp.

◆ couponQle_

const QuantExt::OvernightIndexedCoupon* couponQle_
private

Definition at line 54 of file brlcdicouponpricer.hpp.

◆ index_

QuantLib::ext::shared_ptr<BRLCdi> index_
private

The index underlying the coupon to be priced.

Definition at line 57 of file brlcdicouponpricer.hpp.