Coverage Report

Created: 2025-10-14 06:32

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/instruments/bonds/fixedratebond.cpp
Line
Count
Source
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
 <https://www.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
29
namespace QuantLib {
30
31
    FixedRateBond::FixedRateBond(Natural settlementDays,
32
                                 Real faceAmount,
33
                                 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
0
     : Bond(settlementDays,
46
0
            paymentCalendar==Calendar() ? schedule.calendar() : paymentCalendar,
47
0
            issueDate),
48
0
       frequency_(schedule.hasTenor() ? schedule.tenor().frequency() : NoFrequency),
49
0
       dayCounter_(accrualDayCounter),
50
0
       firstPeriodDayCounter_(firstPeriodDayCounter) {
51
52
0
        maturityDate_ = schedule.endDate();
53
54
0
        cashflows_ = FixedRateLeg(std::move(schedule))
55
0
            .withNotionals(faceAmount)
56
0
            .withCouponRates(coupons, accrualDayCounter)
57
0
            .withFirstPeriodDayCounter(firstPeriodDayCounter)
58
0
            .withPaymentCalendar(calendar_)
59
0
            .withPaymentAdjustment(paymentConvention)
60
0
            .withExCouponPeriod(exCouponPeriod,
61
0
                                exCouponCalendar,
62
0
                                exCouponConvention,
63
0
                                exCouponEndOfMonth);
64
65
0
        addRedemptionsToCashflows(std::vector<Real>(1, redemption));
66
67
0
        QL_ENSURE(!cashflows().empty(), "bond with no cashflows!");
68
0
        QL_ENSURE(redemptions_.size() == 1, "multiple redemptions created");
69
0
    }
Unexecuted instantiation: QuantLib::FixedRateBond::FixedRateBond(unsigned int, double, QuantLib::Schedule, std::__1::vector<double, std::__1::allocator<double> > const&, QuantLib::DayCounter const&, QuantLib::BusinessDayConvention, double, QuantLib::Date const&, QuantLib::Calendar const&, QuantLib::Period const&, QuantLib::Calendar const&, QuantLib::BusinessDayConvention, bool, QuantLib::DayCounter const&)
Unexecuted instantiation: QuantLib::FixedRateBond::FixedRateBond(unsigned int, double, QuantLib::Schedule, std::__1::vector<double, std::__1::allocator<double> > const&, QuantLib::DayCounter const&, QuantLib::BusinessDayConvention, double, QuantLib::Date const&, QuantLib::Calendar const&, QuantLib::Period const&, QuantLib::Calendar const&, QuantLib::BusinessDayConvention, bool, QuantLib::DayCounter const&)
70
71
}