Financial instruments


Detailed Description

Since version 0.3.4, the Instrument class was reworked as shown in the following figure.

UML diagram

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:

  1. implement the isExpired method, and completely override the performCalculations method so that it bypasses the pricing-engine machinery. If the class declared any other results beside NPV_ and errorEstimate_, the setupExpired 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 the Option class.
  2. define suitable argument and result classes for the instrument and implement the isExpired and setupArguments methods, reusing the pricing-engine machinery provided by the default performCalculations 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, the setupExpired 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  BarrierOption
 Barrier option on a single asset. More...

class  BasketOption
 Basket option on a number of assets. 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  DividendVanillaOption
 Single-asset vanilla option (no barriers) with discrete dividends. More...

class  EuropeanOption
 European option on a single asset. More...

class  ForwardVanillaOption
 Forward version of a vanilla option. More...

class  QuantoForwardVanillaOption
 Quanto version of a forward vanilla option. More...

class  QuantoVanillaOption
 quanto version of a vanilla option More...

class  SimpleSwap
 Simple fixed-rate vs Libor swap. 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...


QuantLib.org
QuantLib
Hosted by
SourceForge.net Logo
Documentation generated by
doxygen