Coercion

Overview

QuantLibXL supports a feature called Coercion in which the arguments to a function may be automatically converted from one datatype to another. For example, wherever a QuantLibXL function expects a quote, any of the following may be supplied:

  • The ID of a quote object that was previously constructed with a call to qlSimpleQuote().
  • The ID of a quote handle object that was previously constructed with a call to qlHandleQuote().
  • A number, which the coercion feature will use to automatically create a temporary quote object on the fly.

Supported Coercions

The table below summarizes the automatic coercions supported by QuantLibXL:

Value RequiredSupported Inputs
Quote
  • ID of a Quote object as returned by qlSimpleQuote()
  • ID of a Quote handle object as returned by qlHandleQuote()
  • number representing quote value
  • this logic is applied to the following Quote classes: FuturesConvAdjustmentQuote, Quote, SimpleQuote
Date
  • An integer representing the offset in days since 1 January 1970. This is the format passed by Excel.
  • A period, to be used as the offset from the current evaluation date. For example, where a function expects a date, and the current evaluation date is 6 July 2005, and the user supplies the string "2Y", then the function receives the date value 6 July 2007.
  • An IMM code such as Z7, which maps to Wed, 20-Dec-2017, i.e. to the corresponding IMM date in the forward decade starting from the current evaluation date.
TermStructure
  • ID of a TermStructure object as returned by a function such as qlPiecewiseYieldCurve ()
  • ID of a TermStructure handle object as returned by qlRelinkableHandleYieldTermStructure()
  • this logic is applied to the following TermStructure classes: SwaptionVolatilityCube, SwaptionVolatilityDiscrete, SwaptionVolatilityMatrix, SwaptionVolatilityStructure, SwaptionVolCube1, TermStructure, YieldTermStructure

Lists

Functions which expect a list of values accept input in either of the following two forms:

  • A reference to an Excel range of values
  • A string comprising a semicolon-delimited list of values