QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
floatingratebond.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2007 Ferdinando Ametrano
5 Copyright (C) 2007 Chiara Fornarola
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
24#include <ql/time/schedule.hpp>
27
28namespace QuantLib {
29
31 Natural settlementDays,
32 Real faceAmount,
33 Schedule schedule,
34 const ext::shared_ptr<IborIndex>& iborIndex,
35 const DayCounter& paymentDayCounter,
36 BusinessDayConvention paymentConvention,
37 Natural fixingDays,
38 const std::vector<Real>& gearings,
39 const std::vector<Spread>& spreads,
40 const std::vector<Rate>& caps,
41 const std::vector<Rate>& floors,
42 bool inArrears,
43 Real redemption,
44 const Date& issueDate,
45 const Period& exCouponPeriod,
46 const Calendar& exCouponCalendar,
47 const BusinessDayConvention exCouponConvention,
48 bool exCouponEndOfMonth)
49 : Bond(settlementDays, schedule.calendar(), issueDate) {
50
51 maturityDate_ = schedule.endDate();
52
53 cashflows_ = IborLeg(std::move(schedule), iborIndex)
54 .withNotionals(faceAmount)
55 .withPaymentDayCounter(paymentDayCounter)
56 .withPaymentAdjustment(paymentConvention)
57 .withFixingDays(fixingDays)
58 .withGearings(gearings)
59 .withSpreads(spreads)
60 .withCaps(caps)
61 .withFloors(floors)
62 .inArrears(inArrears)
63 .withExCouponPeriod(exCouponPeriod, exCouponCalendar, exCouponConvention, exCouponEndOfMonth);
64
65 addRedemptionsToCashflows(std::vector<Real>(1, redemption));
66
67 QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");
68 QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created");
69
70 registerWith(iborIndex);
71 }
72
73}
Base bond class.
Definition: bond.hpp:59
Leg redemptions_
Definition: bond.hpp:303
void addRedemptionsToCashflows(const std::vector< Real > &redemptions=std::vector< Real >())
Definition: bond.cpp:315
const Leg & cashflows() const
Definition: bond.hpp:344
Leg cashflows_
Definition: bond.hpp:302
const ext::shared_ptr< CashFlow > & redemption() const
Definition: bond.cpp:140
Date maturityDate_
Definition: bond.hpp:305
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
FloatingRateBond(Natural settlementDays, Real faceAmount, Schedule schedule, const ext::shared_ptr< IborIndex > &iborIndex, const DayCounter &accrualDayCounter, BusinessDayConvention paymentConvention=Following, Natural fixingDays=Null< Natural >(), const std::vector< Real > &gearings={ 1.0 }, const std::vector< Spread > &spreads={ 0.0 }, const std::vector< Rate > &caps={}, const std::vector< Rate > &floors={}, bool inArrears=false, Real redemption=100.0, const Date &issueDate=Date(), const Period &exCouponPeriod=Period(), const Calendar &exCouponCalendar=Calendar(), BusinessDayConvention exCouponConvention=Unadjusted, bool exCouponEndOfMonth=false)
helper class building a sequence of capped/floored ibor-rate coupons
Definition: iborcoupon.hpp:134
IborLeg & withSpreads(Spread spread)
Definition: iborcoupon.cpp:212
IborLeg & withPaymentAdjustment(BusinessDayConvention)
Definition: iborcoupon.cpp:177
IborLeg & withPaymentDayCounter(const DayCounter &)
Definition: iborcoupon.cpp:172
IborLeg & inArrears(bool flag=true)
Definition: iborcoupon.cpp:242
IborLeg & withFloors(Rate floor)
Definition: iborcoupon.cpp:232
IborLeg & withNotionals(Real notional)
Definition: iborcoupon.cpp:162
IborLeg & withGearings(Real gearing)
Definition: iborcoupon.cpp:202
IborLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
Definition: iborcoupon.cpp:252
IborLeg & withCaps(Rate cap)
Definition: iborcoupon.cpp:222
IborLeg & withFixingDays(Natural fixingDays)
Definition: iborcoupon.cpp:192
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Payment schedule.
Definition: schedule.hpp:40
const Date & endDate() const
Definition: schedule.hpp:184
#define QL_ENSURE(condition, message)
throw an error if the given post-condition is not verified
Definition: errors.hpp:130
floating-rate bond
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Coupon paying a Libor-type index.
base class for Inter-Bank-Offered-Rate indexes
Definition: any.hpp:35
date schedule
Predetermined cash flow.
swap-rate indexes