Coverage Report

Created: 2026-10-31 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/instrument.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, 2005, 2006, 2007 StatPro Italia srl
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
 <https://www.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/instrument.hpp>
22
#include <ql/settings.hpp>
23
24
namespace QuantLib {
25
26
    Instrument::Instrument()
27
605k
    : NPV_(Null<Real>()), errorEstimate_(Null<Real>()) {
28
        // this makes sense in general (if the evaluation date
29
        // changes, you probably want to recalculate) and can also
30
        // help avoid some edge cases when lazy objects only forward
31
        // their first notification.
32
605k
        registerWith(Settings::instance().evaluationDate());
33
605k
    }
34
35
535k
    void Instrument::setPricingEngine(const ext::shared_ptr<PricingEngine>& e) {
36
535k
        if (engine_ != nullptr)
37
0
            unregisterWith(engine_);
38
535k
        engine_ = e;
39
535k
        if (engine_ != nullptr)
40
535k
            registerWith(engine_);
41
        // trigger (lazy) recalculation and notify observers
42
535k
        update();
43
535k
    }
44
45
0
    void Instrument::setupArguments(PricingEngine::arguments*) const {
46
        QL_FAIL("Instrument::setupArguments() not implemented");
47
0
    }
48
49
}