32 : legs_(2), payer_(2),
33 legNPV_(2, 0.0), legBPS_(2, 0.0),
34 startDiscounts_(2, 0.0), endDiscounts_(2, 0.0),
35 npvDateDiscount_(0.0) {
40 for (
auto& i :
legs_[0])
42 for (
auto& i :
legs_[1])
47 const std::vector<bool>& payer)
48 : legs_(legs), payer_(legs.size(), 1.0),
49 legNPV_(legs.size(), 0.0), legBPS_(legs.size(), 0.0),
50 startDiscounts_(legs.size(), 0.0), endDiscounts_(legs.size(), 0.0),
51 npvDateDiscount_(0.0) {
53 "size mismatch between payer (" <<
payer.size() <<
54 ") and legs (" <<
legs_.size() <<
")");
57 for (
auto& i :
legs_[j])
63 : legs_(legs), payer_(legs),
64 legNPV_(legs, 0.0), legBPS_(legs, 0.0),
65 startDiscounts_(legs, 0.0), endDiscounts_(legs, 0.0),
66 npvDateDiscount_(0.0) {}
70 Leg::const_iterator i;
71 for (i =
leg.begin(); i !=
leg.end(); ++i)
72 if (!(*i)->hasOccurred())
103 "wrong number of leg NPV returned");
111 "wrong number of leg BPS returned");
119 "wrong number of leg start discounts returned");
128 "wrong number of leg end discounts returned");
164 for (
auto& k :
leg) {
173 "number of legs and multipliers differ");
188 return out <<
"Payer";
190 return out <<
"Receiver";
Cash-flow analysis functions.
static Date maturityDate(const Leg &leg)
static Date startDate(const Leg &leg)
virtual void fetchResults(const PricingEngine::results *) const
virtual void setupExpired() const
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
void validate() const override
std::vector< Real > payer
std::vector< Real > legBPS
DiscountFactor npvDateDiscount
std::vector< DiscountFactor > endDiscounts
std::vector< DiscountFactor > startDiscounts
std::vector< Real > legNPV
DiscountFactor endDiscounts(Size j) const
DiscountFactor npvDateDiscount_
const std::vector< Leg > & legs() const
void setupArguments(PricingEngine::arguments *) const override
Size numberOfLegs() const
bool isExpired() const override
returns whether the instrument might have value greater than zero.
Real legBPS(Size j) const
void deepUpdate() override
virtual Date startDate() const
std::vector< Real > legNPV_
const Leg & leg(Size j) const
DiscountFactor npvDateDiscount() const
std::vector< Real > legBPS_
Swap(const Leg &firstLeg, const Leg &secondLeg)
virtual Date maturityDate() const
std::vector< DiscountFactor > startDiscounts_
Real legNPV(Size j) const
void setupExpired() const override
DiscountFactor startDiscounts(Size j) const
void fetchResults(const PricingEngine::results *) const override
std::vector< DiscountFactor > endDiscounts_
std::vector< Real > payer_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Coupon paying a variable index-based rate.
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
ext::shared_ptr< YieldTermStructure > r
Interest-rate term structure.