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

Standard BRL CDI swap. More...

#include <qle/instruments/brlcdiswap.hpp>

+ Inheritance diagram for BRLCdiSwap:
+ Collaboration diagram for BRLCdiSwap:

Public Member Functions

 BRLCdiSwap (Type type, QuantLib::Real nominal, const QuantLib::Date &startDate, const QuantLib::Date &endDate, QuantLib::Rate fixedRate, const QuantLib::ext::shared_ptr< BRLCdi > &overnightIndex, QuantLib::Spread spread=0.0, bool telescopicValueDates=false)
 

Results

QuantLib::Date startDate_
 
QuantLib::Date endDate_
 
QuantLib::ext::shared_ptr< QuantLib::OvernightIndex > index_
 QuantLib does not implement the method OvernightIndexedSwap::overnightIndex() so I need this. More...
 
QuantLib::Real fixedLegBPS () const
 
QuantLib::Real fairRate () const
 

Detailed Description

Standard BRL CDI swap.

Definition at line 33 of file brlcdiswap.hpp.

Constructor & Destructor Documentation

◆ BRLCdiSwap()

BRLCdiSwap ( Type  type,
QuantLib::Real  nominal,
const QuantLib::Date &  startDate,
const QuantLib::Date &  endDate,
QuantLib::Rate  fixedRate,
const QuantLib::ext::shared_ptr< BRLCdi > &  overnightIndex,
QuantLib::Spread  spread = 0.0,
bool  telescopicValueDates = false 
)

Definition at line 34 of file brlcdiswap.cpp.

36 : OvernightIndexedSwap(type, nominal,
37 Schedule({startDate, endDate}, NullCalendar(),
38 QuantLib::Unadjusted, QuantLib::Unadjusted, 100 * Years),
39 fixedRate, overnightIndex->dayCounter(), overnightIndex, spread, 0, ModifiedFollowing,
40 overnightIndex->fixingCalendar(), telescopicValueDates),
41 startDate_(startDate), endDate_(endDate), index_(overnightIndex) {
42
43 // Need to overwrite the fixed leg with the correct fixed leg for a standard BRL CDI swap
44 // Fixed leg is of the form: N [(1 + k) ^ \delta - 1]
45 // where \delta is the number of BRL business days in the period divided by 252 i.e.
46 // the day count fraction for the period on a Business252 basis.
47 Time dcf = index_->dayCounter().yearFraction(startDate_, endDate_);
48 Real fixedLegPayment = nominal * (pow(1.0 + fixedRate, dcf) - 1.0);
49 Date paymentDate = legs_[0].back()->date();
50 QuantLib::ext::shared_ptr<CashFlow> fixedCashflow = QuantLib::ext::make_shared<SimpleCashFlow>(fixedLegPayment, paymentDate);
51 legs_[0].clear();
52 legs_[0].push_back(fixedCashflow);
53 registerWith(fixedCashflow);
54
55 // Set the pricer on the BRL CDI coupon
56 QL_REQUIRE(legs_[1].size() == 1, "BRLCdiSwap expected exactly one overnight coupon");
57 QuantLib::ext::shared_ptr<QuantLib::OvernightIndexedCoupon> coupon =
58 QuantLib::ext::dynamic_pointer_cast<QuantLib::OvernightIndexedCoupon>(legs_[1][0]);
59 QL_REQUIRE(coupon, "BRLCdiSwap: expected QuantLib::OvernightIndexedCoupon");
60 coupon->setPricer(QuantLib::ext::make_shared<BRLCdiCouponPricer>());
61}
QuantLib::Date endDate_
Definition: brlcdiswap.hpp:47
QuantLib::ext::shared_ptr< QuantLib::OvernightIndex > index_
QuantLib does not implement the method OvernightIndexedSwap::overnightIndex() so I need this.
Definition: brlcdiswap.hpp:49
QuantLib::Date startDate_
Definition: brlcdiswap.hpp:46
CompiledFormula pow(CompiledFormula x, const CompiledFormula &y)

Member Function Documentation

◆ fixedLegBPS()

Real fixedLegBPS ( ) const

Definition at line 63 of file brlcdiswap.cpp.

63 {
64
65 calculate();
66
67 const Spread basisPoint = 1.0e-4;
68 if (!close(endDiscounts_[0], 0.0) && endDiscounts_[0] != Null<DiscountFactor>()) {
69 DiscountFactor df = payer_[0] * endDiscounts_[0];
70 Time dcf = index_->dayCounter().yearFraction(startDate_, endDate_);
71 legBPS_[0] = df * nominal() * (pow(1.0 + fixedRate() + basisPoint, dcf) - pow(1.0 + fixedRate(), dcf));
72 return legBPS_[0];
73 }
74
75 QL_FAIL("BRLCdiSwap cannot calculate fixed leg BPS because end discount is not populated");
76}
+ Here is the call graph for this function:

◆ fairRate()

Real fairRate ( ) const

Definition at line 78 of file brlcdiswap.cpp.

78 {
79
80 calculate();
81
82 if (!close(endDiscounts_[0], 0.0) && endDiscounts_[0] != Null<DiscountFactor>()) {
83 DiscountFactor df = -payer_[0] * endDiscounts_[0];
84 Time dcf = index_->dayCounter().yearFraction(startDate_, endDate_);
85 return pow(overnightLegNPV() / (nominal() * df) + 1.0, 1.0 / dcf) - 1.0;
86 }
87
88 QL_FAIL("BRLCdiSwap cannot calculate fair rate because end discount is not populated");
89}
+ Here is the call graph for this function:

Member Data Documentation

◆ startDate_

QuantLib::Date startDate_
private

Definition at line 46 of file brlcdiswap.hpp.

◆ endDate_

QuantLib::Date endDate_
private

Definition at line 47 of file brlcdiswap.hpp.

◆ index_

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

QuantLib does not implement the method OvernightIndexedSwap::overnightIndex() so I need this.

Definition at line 49 of file brlcdiswap.hpp.