QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
|
Abstract instrument class. More...
#include <instrument.hpp>
Classes | |
class | results |
Public Member Functions | |
Instrument () | |
Inspectors | |
Real | NPV () const |
returns the net present value of the instrument. More... | |
Real | errorEstimate () const |
returns the error estimate on the NPV when available. More... | |
const Date & | valuationDate () const |
returns the date the net present value refers to. More... | |
template<typename T > | |
T | result (const std::string &tag) const |
returns any additional result returned by the pricing engine. More... | |
const std::map< std::string, ext::any > & | additionalResults () const |
returns all additional result returned by the pricing engine. More... | |
virtual bool | isExpired () const =0 |
returns whether the instrument might have value greater than zero. More... | |
Modifiers | |
void | setPricingEngine (const ext::shared_ptr< PricingEngine > &) |
set the pricing engine to be used. More... | |
virtual void | setupArguments (PricingEngine::arguments *) const |
virtual void | fetchResults (const PricingEngine::results *) const |
Public Member Functions inherited from LazyObject | |
LazyObject () | |
~LazyObject () override=default | |
void | update () override |
bool | isCalculated () const |
void | forwardFirstNotificationOnly () |
void | alwaysForwardNotifications () |
void | recalculate () |
void | freeze () |
void | unfreeze () |
Public Member Functions inherited from Observable | |
Observable () | |
Observable (const Observable &) | |
Observable & | operator= (const Observable &) |
Observable (Observable &&)=delete | |
Observable & | operator= (Observable &&)=delete |
virtual | ~Observable ()=default |
void | notifyObservers () |
Public Member Functions inherited from Observer | |
Observer ()=default | |
Observer (const Observer &) | |
Observer & | operator= (const Observer &) |
virtual | ~Observer () |
std::pair< iterator, bool > | registerWith (const ext::shared_ptr< Observable > &) |
void | registerWithObservables (const ext::shared_ptr< Observer > &) |
Size | unregisterWith (const ext::shared_ptr< Observable > &) |
void | unregisterWithAll () |
virtual void | update ()=0 |
virtual void | deepUpdate () |
Protected Member Functions | |
Calculations | |
void | calculate () const override |
virtual void | setupExpired () const |
void | performCalculations () const override |
Protected Member Functions inherited from LazyObject |
Protected Attributes | |
Results | |
The value of this attribute and any other that derived classes might declare must be set during calculation. | |
Real | NPV_ |
Real | errorEstimate_ |
Date | valuationDate_ |
std::map< std::string, ext::any > | additionalResults_ |
ext::shared_ptr< PricingEngine > | engine_ |
Protected Attributes inherited from LazyObject | |
bool | calculated_ = false |
bool | frozen_ = false |
bool | alwaysForward_ |
Additional Inherited Members | |
Public Types inherited from Observer | |
typedef set_type::iterator | iterator |
Abstract instrument class.
This class is purely abstract and defines the interface of concrete instruments which will be derived from this one.
Definition at line 44 of file instrument.hpp.
Instrument | ( | ) |
Real NPV | ( | ) | const |
returns the net present value of the instrument.
Definition at line 167 of file instrument.hpp.
Real errorEstimate | ( | ) | const |
returns the error estimate on the NPV when available.
Definition at line 173 of file instrument.hpp.
const Date & valuationDate | ( | ) | const |
returns the date the net present value refers to.
Definition at line 180 of file instrument.hpp.
T result | ( | const std::string & | tag | ) | const |
returns any additional result returned by the pricing engine.
Definition at line 188 of file instrument.hpp.
const std::map< std::string, ext::any > & additionalResults | ( | ) | const |
returns all additional result returned by the pricing engine.
Definition at line 198 of file instrument.hpp.
|
pure virtual |
returns whether the instrument might have value greater than zero.
Implemented in EnergyFuture, EnergySwap, EnergyVanillaSwap, CDO, CdsOption, NthToDefault, RiskyAssetSwap, RiskyAssetSwapOption, SyntheticCDO, TwoAssetBarrierOption, WriterExtensibleOption, VanillaVPPOption, PathMultiAssetOption, IrregularSwaption, VarianceOption, Bond, CapFloor, CompositeInstrument, CPICapFloor, CreditDefaultSwap, FloatFloatSwaption, Forward, ForwardRateAgreement, YoYInflationCapFloor, MultiAssetOption, NonstandardSwaption, OneAssetOption, OvernightIndexFuture, Stock, Swap, Swaption, VanillaStorageOption, VanillaSwingOption, and VarianceSwap.
void setPricingEngine | ( | const ext::shared_ptr< PricingEngine > & | e | ) |
set the pricing engine to be used.
Definition at line 35 of file instrument.cpp.
|
virtual |
When a derived argument structure is defined for an instrument, this method should be overridden to fill it. This is mandatory in case a pricing engine is used.
Reimplemented in CatBond, EnergyCommodity, CdsOption, NthToDefault, SyntheticCDO, EverestOption, HimalayaOption, HolderExtensibleOption, PagodaOption, PartialTimeBarrierOption, TwoAssetBarrierOption, TwoAssetCorrelationOption, WriterExtensibleOption, VanillaVPPOption, PathMultiAssetOption, IrregularSwaption, ContinuousAveragingAsianOption, DiscreteAveragingAsianOption, BarrierOption, Bond, ConvertibleBond, CapFloor, CliquetOption, ComplexChooserOption, CompoundOption, CPICapFloor, CreditDefaultSwap, DoubleBarrierOption, FloatFloatSwaption, ForwardVanillaOption, YoYInflationCapFloor, ContinuousFloatingLookbackOption, ContinuousFixedLookbackOption, ContinuousPartialFloatingLookbackOption, ContinuousPartialFixedLookbackOption, MargrabeOption, MultiAssetOption, NonstandardSwaption, SimpleChooserOption, Swap, Swaption, VanillaStorageOption, VanillaSwingOption, Option, CallableBond, IrregularSwap, VarianceOption, AssetSwap, CPISwap, FixedVsFloatingSwap, FloatFloatSwap, NonstandardSwap, VarianceSwap, and YearOnYearInflationSwap.
Definition at line 45 of file instrument.cpp.
|
virtual |
When a derived result structure is defined for an instrument, this method should be overridden to read from it. This is mandatory in case a pricing engine is used.
Reimplemented in QuantoDoubleBarrierOption, CatBond, EnergyCommodity, CdsOption, NthToDefault, SyntheticCDO, EverestOption, IrregularSwap, AssetSwap, Bond, CPISwap, CreditDefaultSwap, FixedVsFloatingSwap, FloatFloatSwap, ForwardVanillaOption, MargrabeOption, MultiAssetOption, NonstandardSwap, OneAssetOption, QuantoBarrierOption, QuantoForwardVanillaOption, QuantoVanillaOption, Swap, VarianceSwap, and YearOnYearInflationSwap.
Definition at line 155 of file instrument.hpp.
|
overrideprotectedvirtual |
This method performs all needed calculations by calling the performCalculations method.
Reimplemented from LazyObject.
Definition at line 129 of file instrument.hpp.
|
protectedvirtual |
This method must leave the instrument in a consistent state when the expiration condition is met.
Reimplemented in QuantoDoubleBarrierOption, CDO, CdsOption, NthToDefault, RiskyAssetSwap, SyntheticCDO, PathMultiAssetOption, IrregularSwap, AssetSwap, Bond, CPISwap, CreditDefaultSwap, FixedVsFloatingSwap, FloatFloatSwap, ForwardRateAgreement, MultiAssetOption, NonstandardSwap, OneAssetOption, QuantoBarrierOption, QuantoForwardVanillaOption, QuantoVanillaOption, Swap, VarianceSwap, and YearOnYearInflationSwap.
Definition at line 140 of file instrument.hpp.
|
overrideprotectedvirtual |
In case a pricing engine is not used, this method must be overridden to perform the actual calculations and set any needed results. In case a pricing engine is used, the default implementation can be used.
Implements LazyObject.
Reimplemented in BondForward, CompositeInstrument, Forward, ForwardRateAgreement, OvernightIndexFuture, and Stock.
Definition at line 146 of file instrument.hpp.
|
mutableprotected |
Definition at line 106 of file instrument.hpp.
|
protected |
Definition at line 106 of file instrument.hpp.
|
mutableprotected |
Definition at line 107 of file instrument.hpp.
|
mutableprotected |
Definition at line 108 of file instrument.hpp.
|
protected |
Definition at line 110 of file instrument.hpp.