### A free/open-source library for quantitative finance

Classes
Financial instruments

## Classes

class | DigitalCoupon
| Digital-payoff coupon. More...
class | CallableBond
| Callable bond base class. More...
class | CallableFixedRateBond
| callable/puttable fixed rate bond More...
class | CallableZeroCouponBond
| callable/puttable zero coupon bond More...
class | Commodity
| Commodity base class. More...
class | EnergyCommodity
| Energy commodity class. More...
class | EnergyFuture
| Energy future. More...
class | CompoundOption
| Compound option on a single asset. More...
class | MargrabeOption
| Margrabe option on two assets. More...
class | PagodaOption
| Roofed Asian option on a number of assets. More...
class | VarianceOption
| Variance option. More...
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 | CCTEU
class | BTP
| Italian BTP (Buono Poliennali del Tesoro) fixed rate bond. More...
class | CmsRateBond
| CMS-rate bond. More...
class | CPIBond
class | FixedRateBond
| fixed-rate bond More...
class | FloatingRateBond
| floating-rate bond (possibly capped and/or floored) More...
class | ZeroCouponBond
| zero-coupon bond 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 | CompositeInstrument
| Composite instrument More...
class | CreditDefaultSwap
| Credit default swap. More...
class | DividendBarrierOption
| Single-asset barrier option with discrete dividends. More...
class | DividendVanillaOption
| Single-asset vanilla option (no barriers) with discrete dividends. More...
class | EuropeanOption
| European option on a single asset. More...
class | FixedRateBondForward
| Forward contract on a fixed-rate bond More...
class | Forward
| Abstract base forward class. More...
class | ForwardVanillaOption
| Forward version of a vanilla option More...
class | YoYInflationCapFloor
| Base class for yoy inflation cap-like instruments. More...
class | YoYInflationCap
| Concrete YoY Inflation cap class. More...
class | YoYInflationFloor
| Concrete YoY Inflation floor class. More...
class | YoYInflationCollar
| Concrete YoY Inflation collar class. More...
class | ContinuousFloatingLookbackOption
| Continuous-floating lookback option. More...
class | ContinuousFixedLookbackOption
| Continuous-fixed lookback option. More...
class | QuantoBarrierOption
| Quanto version of a barrier 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 | VanillaSwap
| Plain-vanilla swap: fix vs floating leg. More...
class | VarianceSwap
| Variance swap. More...

## Detailed Description

Since version 0.3.4, the `Instrument` 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:

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.