Coverage Report

Created: 2025-08-05 06:45

/src/quantlib/ql/indexes/ibor/custom.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
#include <ql/indexes/ibor/custom.hpp>
4
#include <utility>
5
6
namespace QuantLib {
7
8
    CustomIborIndex::CustomIborIndex(const std::string& familyName,
9
                                     const Period& tenor,
10
                                     Natural settlementDays,
11
                                     const Currency& currency,
12
                                     const Calendar& fixingCalendar,
13
                                     Calendar  valueCalendar,
14
                                     Calendar  maturityCalendar,
15
                                     BusinessDayConvention convention,
16
                                     bool endOfMonth,
17
                                     const DayCounter& dayCounter,
18
                                     const Handle<YieldTermStructure>& h)
19
0
    : IborIndex(familyName, tenor, settlementDays, currency, fixingCalendar,
20
0
                convention, endOfMonth, dayCounter, h),
21
0
      valueCalendar_(std::move(valueCalendar)), maturityCalendar_(std::move(maturityCalendar)) {}
22
23
0
    Date CustomIborIndex::fixingDate(const Date& valueDate) const {
24
0
        Date fixingDate = valueCalendar_.advance(valueDate,
25
0
            -static_cast<Integer>(fixingDays_), Days);
26
0
        return fixingCalendar().adjust(fixingDate, Preceding);
27
0
    }
28
29
0
    Date CustomIborIndex::valueDate(const Date& fixingDate) const {
30
31
0
        QL_REQUIRE(isValidFixingDate(fixingDate),
32
0
                   "Fixing date " << fixingDate << " is not valid");
33
34
0
        Date d = valueCalendar_.advance(fixingDate, fixingDays_, Days);
35
0
        return maturityCalendar_.adjust(d);
36
0
    }
37
38
0
    Date CustomIborIndex::maturityDate(const Date& valueDate) const {
39
0
        return maturityCalendar_.advance(valueDate, tenor_, convention_,
40
0
                                         endOfMonth_);
41
0
    }
42
43
    ext::shared_ptr<IborIndex> CustomIborIndex::clone(
44
0
            const Handle<YieldTermStructure>& h) const {
45
0
        return ext::make_shared<CustomIborIndex>(
46
0
            familyName_, tenor_, fixingDays_, currency_, fixingCalendar(),
47
0
            valueCalendar_, maturityCalendar_, convention_, endOfMonth_,
48
0
            dayCounter_, h);
49
0
    }
50
51
}