Financial instruments
Detailed Description
Since version 0.3.4, theInstrument
class was reworked as shown in the following figure.

On the one hand, the checking of the expiration condition is now performed in a method isExpired()
separated from the actual calculation, and a setupExpired()
method is provided. The latter sets the NPV to 0.0 and can be extended in derived classes should any other results be returned.
On the other hand, the pricing-engine machinery previously contained in the Option class was moved upwards to the Instrument class. Also, the setupEngine()
method was replaced by a setupArguments(Arguments*)
method. This allows one to cleanly implement containment of instruments with code such as:
class FooArguments : public Arguments { ... }; class Foo : public Instrument { public: void setupArguments(Arguments*); ... }; class FooOptionArguments : public FooArguments { ... }; class FooOption : public Option { private: Foo underlying_; public: void setupArguments(Arguments* args) { underlying_.setupArguments(args); // set the option-specific part } ... };
which was more difficult to write with setupEngine()
.
Therefore, there are now two ways to inherit from Instrument
, namely:
- implement the
isExpired
method, and completely override theperformCalculations
method so that it bypasses the pricing-engine machinery. If the class declared any other results besideNPV_
anderrorEstimate_
, thesetupExpired
method should also be extended so that those results are set to a value suitable for an expired instrument. This was the migration path taken for all instruments not previously deriving from theOption
class. - define suitable argument and result classes for the instrument and implement the
isExpired
andsetupArguments
methods, reusing the pricing-engine machinery provided by the defaultperformCalculations
method. The latter can be extended by first calling the default implementation and then performing any additional tasks required by the instrument---most often, copying additional results from the pricing engine results to the corresponding data members of the instrument. As in the previous case, thesetupExpired
method can be extended to account for such extra data members.
Classes | |
class | ContinuousAveragingAsianOption |
Continuous-averaging Asian option. More... | |
class | DiscreteAveragingAsianOption |
Discrete-averaging Asian option. More... | |
class | AssetSwap |
Bullet bond vs Libor swap. More... | |
class | BarrierOption |
Barrier option on a single asset. More... | |
class | BasketOption |
Basket option on a number of assets. More... | |
class | Bond |
Base bond class. More... | |
class | CapFloor |
Base class for cap-like instruments. More... | |
class | Cap |
Concrete cap class. More... | |
class | Floor |
Concrete floor class. More... | |
class | Collar |
Concrete collar class. More... | |
class | CliquetOption |
cliquet (Ratchet) option More... | |
class | CmsRateBond |
CMS-rate bond. More... | |
class | CompositeInstrument |
Composite instrument More... | |
class | DividendVanillaOption |
Single-asset vanilla option (no barriers) with discrete dividends. More... | |
class | EuropeanOption |
European option on a single asset. More... | |
class | FixedRateBond |
fixed-rate bond More... | |
class | FixedRateBondForward |
Forward contract on a fixed-rate bond More... | |
class | FloatingRateBond |
floating-rate bond (possibly capped and/or floored) More... | |
class | Forward |
Abstract base forward class. More... | |
class | ForwardRateAgreement |
Forward rate agreement (FRA) class More... | |
class | ForwardVanillaOption |
Forward version of a vanilla option More... | |
class | ContinuousFloatingLookbackOption |
Continuous-floating lookback option. More... | |
class | ContinuousFixedLookbackOption |
Continuous-fixed lookback option. More... | |
class | QuantoForwardVanillaOption |
Quanto version of a forward vanilla option. More... | |
class | QuantoVanillaOption |
quanto version of a vanilla option More... | |
class | Stock |
Simple stock class. More... | |
class | Swap |
Interest rate swap. More... | |
class | Swaption |
Swaption class More... | |
class | VanillaOption |
Vanilla option (no discrete dividends, no barriers) on a single asset. More... | |
class | VarianceSwap |
Variance swap. More... | |
class | ZeroCouponBond |
zero-coupon bond More... |