/src/quantlib/ql/instrument.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 | | /* |
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 | 573k | : 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 | 573k | registerWith(Settings::instance().evaluationDate()); |
33 | 573k | } |
34 | | |
35 | 488k | void Instrument::setPricingEngine(const ext::shared_ptr<PricingEngine>& e) { |
36 | 488k | if (engine_ != nullptr) |
37 | 0 | unregisterWith(engine_); |
38 | 488k | engine_ = e; |
39 | 488k | if (engine_ != nullptr) |
40 | 488k | registerWith(engine_); |
41 | | // trigger (lazy) recalculation and notify observers |
42 | 488k | update(); |
43 | 488k | } |
44 | | |
45 | 0 | void Instrument::setupArguments(PricingEngine::arguments*) const { |
46 | 0 | QL_FAIL("Instrument::setupArguments() not implemented"); |
47 | 0 | } |
48 | | |
49 | | } |