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

Discounting Swap Engine - Multi Curve. More...

#include <qle/pricingengines/discountingswapenginemulticurve.hpp>

+ Inheritance diagram for DiscountingSwapEngineMultiCurve:
+ Collaboration diagram for DiscountingSwapEngineMultiCurve:

Public Member Functions

 DiscountingSwapEngineMultiCurve (const Handle< YieldTermStructure > &discountCurve=Handle< YieldTermStructure >(), bool minimalResults=true, boost::optional< bool > includeSettlementDateFlows=boost::none, Date settlementDate=Date(), Date npvDate=Date())
 
void calculate () const override
 
Handle< YieldTermStructure > discountCurve () const
 

Private Attributes

Handle< YieldTermStructure > discountCurve_
 
bool minimalResults_
 
boost::optional< boolincludeSettlementDateFlows_
 
Date settlementDate_
 
Date npvDate_
 
QuantLib::ext::shared_ptr< AmountImpl > impl_
 

Detailed Description

Discounting Swap Engine - Multi Curve.

This class prices a swap with numerous simplifications in the case of an ibor coupon leg to speed up the calculations:

Definition at line 47 of file discountingswapenginemulticurve.hpp.

Constructor & Destructor Documentation

◆ DiscountingSwapEngineMultiCurve()

DiscountingSwapEngineMultiCurve ( const Handle< YieldTermStructure > &  discountCurve = Handle<YieldTermStructure>(),
bool  minimalResults = true,
boost::optional< bool includeSettlementDateFlows = boost::none,
Date  settlementDate = Date(),
Date  npvDate = Date() 
)

Definition at line 118 of file discountingswapenginemulticurve.cpp.

122 : discountCurve_(discountCurve), minimalResults_(minimalResults),
123 includeSettlementDateFlows_(includeSettlementDateFlows), settlementDate_(settlementDate), npvDate_(npvDate),
124 impl_(new AmountImpl) {
125
126 registerWith(discountCurve_);
127
128 if (minimalResults_) {
129 impl_->amountGetter_.reset(new AmountGetter);
130 } else {
131 impl_->amountGetter_.reset(new AdditionalAmountGetter);
132 }
133}

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 135 of file discountingswapenginemulticurve.cpp.

135 {
136 QL_REQUIRE(!discountCurve_.empty(), "Empty discounting "
137 "term structure handle");
138
139 // Instrument settlement date
140 Date referenceDate = discountCurve_->referenceDate();
141 Date settlementDate = settlementDate_;
142 if (settlementDate_ == Date()) {
143 settlementDate = referenceDate;
144 } else {
145 QL_REQUIRE(settlementDate >= referenceDate, "settlement date (" << settlementDate
146 << ") before "
147 "discount curve reference date ("
148 << referenceDate << ")");
149 }
150
151 // - Instrument::results
152 results_.value = 0.0;
153 results_.errorEstimate = Null<Real>();
154 results_.valuationDate = npvDate_;
155 if (npvDate_ == Date()) {
156 results_.valuationDate = referenceDate;
157 } else {
158 QL_REQUIRE(npvDate_ >= referenceDate, "npv date (" << npvDate_
159 << ") before "
160 "discount curve reference date ("
161 << referenceDate << ")");
162 }
163
164 // - Swap::results
165 Size numLegs = arguments_.legs.size();
166 results_.legNPV.resize(numLegs);
167 results_.legBPS.resize(numLegs);
168 results_.startDiscounts.resize(numLegs);
169 results_.endDiscounts.resize(numLegs);
170 results_.npvDateDiscount = discountCurve_->discount(results_.valuationDate);
171
172 bool includeRefDateFlows =
173 includeSettlementDateFlows_ ? *includeSettlementDateFlows_ : Settings::instance().includeReferenceDateEvents();
174
175 const Spread bp = 1.0e-4;
176
177 for (Size i = 0; i < numLegs; i++) {
178
179 Leg leg = arguments_.legs[i];
180 results_.legNPV[i] = 0.0;
181 results_.legBPS[i] = 0.0;
182
183 // Call amount() method of underlying coupon for first coupon.
184 impl_->amountGetter_->setCallAmount(true);
185
186 for (Size j = 0; j < leg.size(); j++) {
187
188 /* Exclude cashflows that have occurred taking into account the
189 settlement date and includeSettlementDateFlows flag */
190 if (leg[j]->hasOccurred(settlementDate, includeRefDateFlows)) {
191 continue;
192 }
193
194 DiscountFactor discount = discountCurve_->discount(leg[j]->date());
195 leg[j]->accept(*(impl_->amountGetter_));
196 results_.legNPV[i] += impl_->amountGetter_->amount() * discount;
197 results_.legBPS[i] += impl_->amountGetter_->bpsFactor() * discount;
198
199 // For all coupons after second do not call amount(), since for those
200 // we can be sure that they are not fixed yet
201 if (j == 1)
202 impl_->amountGetter_->setCallAmount(false);
203 }
204
205 results_.legNPV[i] *= arguments_.payer[i];
206 results_.legNPV[i] /= results_.npvDateDiscount;
207 results_.legBPS[i] *= arguments_.payer[i] * bp;
208 results_.legBPS[i] /= results_.npvDateDiscount;
209 results_.value += results_.legNPV[i];
210 }
211}
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

◆ discountCurve()

Handle< YieldTermStructure > discountCurve ( ) const

Definition at line 54 of file discountingswapenginemulticurve.hpp.

54{ return discountCurve_; }

Member Data Documentation

◆ discountCurve_

Handle<YieldTermStructure> discountCurve_
private

Definition at line 57 of file discountingswapenginemulticurve.hpp.

◆ minimalResults_

bool minimalResults_
private

Definition at line 58 of file discountingswapenginemulticurve.hpp.

◆ includeSettlementDateFlows_

boost::optional<bool> includeSettlementDateFlows_
private

Definition at line 59 of file discountingswapenginemulticurve.hpp.

◆ settlementDate_

Date settlementDate_
private

Definition at line 60 of file discountingswapenginemulticurve.hpp.

◆ npvDate_

Date npvDate_
private

Definition at line 61 of file discountingswapenginemulticurve.hpp.

◆ impl_

QuantLib::ext::shared_ptr<AmountImpl> impl_
private

Definition at line 64 of file discountingswapenginemulticurve.hpp.