QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
fixedratebond.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004 Jeff Yu
5 Copyright (C) 2004 M-Dimension Consulting Inc.
6 Copyright (C) 2005, 2006, 2007 StatPro Italia srl
7 Copyright (C) 2007, 2008, 2010 Ferdinando Ametrano
8 Copyright (C) 2009 Piter Dias
9
10 This file is part of QuantLib, a free-software/open-source library
11 for financial quantitative analysts and developers - http://quantlib.org/
12
13 QuantLib is free software: you can redistribute it and/or modify it
14 under the terms of the QuantLib license. You should have received a
15 copy of the license along with this program; if not, please email
16 <quantlib-dev@lists.sf.net>. The license is also available online at
17 <http://quantlib.org/license.shtml>.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the license for more details.
22*/
23
24#include <ql/instruments/bonds/fixedratebond.hpp>
25#include <ql/cashflows/cashflowvectors.hpp>
26#include <ql/cashflows/simplecashflow.hpp>
27#include <ql/time/schedule.hpp>
28
29namespace QuantLib {
30
32 Real faceAmount,
33 const Schedule& schedule,
34 const std::vector<Rate>& coupons,
35 const DayCounter& accrualDayCounter,
36 BusinessDayConvention paymentConvention,
37 Real redemption,
38 const Date& issueDate,
39 const Calendar& paymentCalendar,
40 const Period& exCouponPeriod,
41 const Calendar& exCouponCalendar,
42 const BusinessDayConvention exCouponConvention,
43 bool exCouponEndOfMonth,
44 const DayCounter& firstPeriodDayCounter)
45 : Bond(settlementDays,
46 paymentCalendar==Calendar() ? schedule.calendar() : paymentCalendar,
47 issueDate),
48 frequency_(schedule.hasTenor() ? schedule.tenor().frequency() : NoFrequency),
49 dayCounter_(accrualDayCounter),
50 firstPeriodDayCounter_(firstPeriodDayCounter) {
51
52 maturityDate_ = schedule.endDate();
53
54 cashflows_ = FixedRateLeg(schedule)
55 .withNotionals(faceAmount)
56 .withCouponRates(coupons, accrualDayCounter)
59 .withPaymentAdjustment(paymentConvention)
60 .withExCouponPeriod(exCouponPeriod,
61 exCouponCalendar,
62 exCouponConvention,
63 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
71}
Base bond class.
Definition: bond.hpp:59
Calendar calendar_
Definition: bond.hpp:285
Leg redemptions_
Definition: bond.hpp:289
void addRedemptionsToCashflows(const std::vector< Real > &redemptions=std::vector< Real >())
Definition: bond.cpp:304
const Leg & cashflows() const
Definition: bond.hpp:330
Leg cashflows_
Definition: bond.hpp:288
const ext::shared_ptr< CashFlow > & redemption() const
Definition: bond.cpp:140
Date maturityDate_
Definition: bond.hpp:291
calendar class
Definition: calendar.hpp:61
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
FixedRateBond(Natural settlementDays, Real faceAmount, const Schedule &schedule, const std::vector< Rate > &coupons, const DayCounter &accrualDayCounter, BusinessDayConvention paymentConvention=Following, Real redemption=100.0, const Date &issueDate=Date(), const Calendar &paymentCalendar=Calendar(), const Period &exCouponPeriod=Period(), const Calendar &exCouponCalendar=Calendar(), BusinessDayConvention exCouponConvention=Unadjusted, bool exCouponEndOfMonth=false, const DayCounter &firstPeriodDayCounter=DayCounter())
simple annual compounding coupon rates
const DayCounter & firstPeriodDayCounter() const
helper class building a sequence of fixed rate coupons
FixedRateLeg & withNotionals(Real)
FixedRateLeg & withPaymentCalendar(const Calendar &)
FixedRateLeg & withPaymentAdjustment(BusinessDayConvention)
FixedRateLeg & withCouponRates(Rate, const DayCounter &paymentDayCounter, Compounding comp=Simple, Frequency freq=Annual)
FixedRateLeg & withFirstPeriodDayCounter(const DayCounter &)
FixedRateLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
Payment schedule.
Definition: schedule.hpp:40
const Date & endDate() const
Definition: schedule.hpp:184
BusinessDayConvention
Business Day conventions.
@ NoFrequency
null frequency
Definition: frequency.hpp:37
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Definition: any.hpp:35