QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
instrument.cpp
Go to the documentation of this file.
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 <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/instrument.hpp>
22#include <ql/settings.hpp>
23
24namespace QuantLib {
25
27 : 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 registerWith(Settings::instance().evaluationDate());
33 }
34
35 void Instrument::setPricingEngine(const ext::shared_ptr<PricingEngine>& e) {
36 if (engine_ != nullptr)
38 engine_ = e;
39 if (engine_ != nullptr)
41 // trigger (lazy) recalculation and notify observers
42 update();
43 }
44
46 QL_FAIL("Instrument::setupArguments() not implemented");
47 }
48
49}
ext::shared_ptr< PricingEngine > engine_
Definition: instrument.hpp:110
void setPricingEngine(const ext::shared_ptr< PricingEngine > &)
set the pricing engine to be used.
Definition: instrument.cpp:35
virtual void setupArguments(PricingEngine::arguments *) const
Definition: instrument.cpp:45
void update() override
Definition: lazyobject.hpp:188
template class providing a null value for a given type.
Definition: null.hpp:76
Size unregisterWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:245
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
QL_REAL Real
real number
Definition: types.hpp:50
Abstract instrument class.
Definition: any.hpp:35
global repository for run-time library settings