Coverage Report

Created: 2025-11-04 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/termstructures/yield/forwardstructure.cpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5
 Copyright (C) 2003, 2004 StatPro Italia srl
6
 Copyright (C) 2009 Ferdinando Ametrano
7
8
 This file is part of QuantLib, a free-software/open-source library
9
 for financial quantitative analysts and developers - http://quantlib.org/
10
11
 QuantLib is free software: you can redistribute it and/or modify it
12
 under the terms of the QuantLib license.  You should have received a
13
 copy of the license along with this program; if not, please email
14
 <quantlib-dev@lists.sf.net>. The license is also available online at
15
 <https://www.quantlib.org/license.shtml>.
16
17
 This program is distributed in the hope that it will be useful, but WITHOUT
18
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 FOR A PARTICULAR PURPOSE.  See the license for more details.
20
*/
21
22
#include <ql/termstructures/yield/forwardstructure.hpp>
23
24
namespace QuantLib {
25
26
    ForwardRateStructure::ForwardRateStructure(const DayCounter& dc)
27
0
    : YieldTermStructure(dc) {}
28
29
    ForwardRateStructure::ForwardRateStructure(
30
                                    const Date& refDate,
31
                                    const Calendar& cal,
32
                                    const DayCounter& dc,
33
                                    const std::vector<Handle<Quote> >& jumps,
34
                                    const std::vector<Date>& jumpDates)
35
0
    : YieldTermStructure(refDate, cal, dc, jumps, jumpDates) {}
36
37
    ForwardRateStructure::ForwardRateStructure(
38
                                    Natural settlDays,
39
                                    const Calendar& cal,
40
                                    const DayCounter& dc,
41
                                    const std::vector<Handle<Quote> >& jumps,
42
                                    const std::vector<Date>& jumpDates)
43
0
    : YieldTermStructure(settlDays, cal, dc, jumps, jumpDates) {}
44
45
0
    Rate ForwardRateStructure::zeroYieldImpl(Time t) const {
46
0
        if (t == 0.0)
47
0
            return forwardImpl(0.0);
48
        // implement smarter integration if plan to use the following code
49
0
        Rate sum = 0.5*forwardImpl(0.0);
50
0
        Size N = 1000;
51
0
        Time dt = t/N;
52
0
        for (Time i=dt; i<t; i+=dt)
53
0
            sum += forwardImpl(i);
54
0
        sum += 0.5*forwardImpl(t);
55
0
        return Rate(sum*dt/t);
56
0
    }
57
58
}