• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lballabio / QuantLib / 19788019547

29 Nov 2025 07:01PM UTC coverage: 74.351% (+0.4%) from 73.914%
19788019547

Pull #2344

github

web-flow
Merge a91e6dcb0 into 08ef06893
Pull Request #2344: add multicurve bootstrap

115 of 129 new or added lines in 6 files covered. (89.15%)

413 existing lines in 27 files now uncovered.

57222 of 76962 relevant lines covered (74.35%)

8798481.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.18
/ql/termstructures/multicurve.cpp
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2

3
/*
4
 Copyright (C) 2025 Eugene Toder
5
 Copyright (C) 2025 Peter Caspers
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

21
#include <ql/termstructures/multicurve.hpp>
22

23
namespace QuantLib {
24

25
    MultiCurve::MultiCurve(Real accuracy)
2✔
26
    : multiCurveBootstrap_(ext::make_shared<MultiCurveBootstrap>(accuracy)) {}
2✔
27

NEW
28
    MultiCurve::MultiCurve(ext::shared_ptr<OptimizationMethod> optimizer,
×
NEW
29
                           ext::shared_ptr<EndCriteria> endCriteria)
×
NEW
30
    : multiCurveBootstrap_(ext::make_shared<MultiCurveBootstrap>(optimizer, endCriteria)) {}
×
31

32
    Handle<YieldTermStructure>
33
    MultiCurve::addCurve(RelinkableHandle<YieldTermStructure>& internalHandle,
3✔
34
                         ext::shared_ptr<YieldTermStructure>&& curve) {
35

36
        QL_REQUIRE(internalHandle.empty(),
3✔
37
                   "internal handle must be empty; was the curve added already?");
38

39
        auto mcProv = ext::dynamic_pointer_cast<MultiCurveBootstrapProvider>(curve);
3✔
40
        QL_REQUIRE(mcProv != nullptr, "curve must not be a MultiCurveBootstrapProvider");
3✔
41

42
        auto bootstrap = mcProv->multiCurveBootstrapContributor();
3✔
43
        QL_REQUIRE(bootstrap, "curve does not provide a valid multi curve bootstrap contributor");
3✔
44

45
        multiCurveBootstrap_->add(bootstrap);
3✔
46

47
        internalHandle.linkTo(ext::shared_ptr<YieldTermStructure>(curve.get(), null_deleter()),
6✔
48
                              false);
49
        Handle<YieldTermStructure> externalHandle(ext::shared_ptr<YieldTermStructure>(
3✔
50
#ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN
51
            ext::static_pointer_cast<MultiCurve>(shared_from_this())
52
#else
53
            shared_from_this()
3✔
54
#endif
55
                ,
56
            curve.get()));
3✔
57
        registerWithObservables(curve);
3✔
58
        curves_.push_back(curve);
3✔
59

60
        return externalHandle;
3✔
61
    }
62

63
    Handle<YieldTermStructure>
64
    MultiCurve::addNonPiecewiseCurve(RelinkableHandle<YieldTermStructure>& internalHandle,
1✔
65
                                     ext::shared_ptr<YieldTermStructure>&& curve) {
66
        QL_REQUIRE(internalHandle.empty(),
1✔
67
                   "internal handle must be empty; was the curve added already?");
68
        QL_REQUIRE(curve != nullptr, "curve must not be null");
1✔
69

70
        multiCurveBootstrap_->addObserver(curve.get());
1✔
71

72
        internalHandle.linkTo(ext::shared_ptr<YieldTermStructure>(curve.get(), null_deleter()),
2✔
73
                              false);
74
        Handle<YieldTermStructure> externalHandle(ext::shared_ptr<YieldTermStructure>(
1✔
75
#ifdef QL_ENABLE_THREAD_SAFE_OBSERVER_PATTERN
76
            ext::static_pointer_cast<MultiCurve>(shared_from_this())
77
#else
78
            shared_from_this()
1✔
79
#endif
80
                ,
81
            curve.get()));
1✔
82
        registerWithObservables(curve);
1✔
83
        curves_.push_back(curve);
1✔
84

85
        return externalHandle;
1✔
86
    }
87

88
    void MultiCurve::update() {
2✔
89
        for (auto const& c : curves_)
4✔
90
            c->update();
2✔
91
    }
2✔
92

93
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc