25#ifndef quantlib_instrument_hpp
26#define quantlib_instrument_hpp
28#include <ql/patterns/lazyobject.hpp>
29#include <ql/pricingengine.hpp>
30#include <ql/utilities/null.hpp>
31#include <ql/time/date.hpp>
59 template <
typename T> T
result(
const std::string& tag)
const;
147 QL_REQUIRE(
engine_,
"null pricing engine");
150 engine_->getArguments()->validate();
158 QL_ENSURE(
results !=
nullptr,
"no results returned from pricing engine");
176 "error estimate not provided");
183 "valuation date not provided");
190 std::map<std::string, ext::any>::const_iterator value =
193 tag <<
" not provided");
194 return ext::any_cast<T>(value->second);
197 inline const std::map<std::string, ext::any>&
std::map< std::string, ext::any > additionalResults
Abstract instrument class.
const std::map< std::string, ext::any > & additionalResults() const
returns all additional result returned by the pricing engine.
void performCalculations() const override
std::map< std::string, ext::any > additionalResults_
T result(const std::string &tag) const
returns any additional result returned by the pricing engine.
Real NPV() const
returns the net present value of the instrument.
void calculate() const override
virtual bool isExpired() const =0
returns whether the instrument might have value greater than zero.
virtual void fetchResults(const PricingEngine::results *) const
Real errorEstimate() const
returns the error estimate on the NPV when available.
ext::shared_ptr< PricingEngine > engine_
const Date & valuationDate() const
returns the date the net present value refers to.
void setPricingEngine(const ext::shared_ptr< PricingEngine > &)
set the pricing engine to be used.
virtual void setupArguments(PricingEngine::arguments *) const
virtual void setupExpired() const
Framework for calculation on demand and result caching.
virtual void calculate() const
template class providing a null value for a given type.