Caplin Trader 4.7.1

Interface: module:caplin/trading/derivation/Derivation

module:caplin/trading/derivation/Derivation

A Derivation specifies how derived field values can be calculated using fields from the trade model as their input.

For example, an ESP FX Trade will have a bid/ask rate that is determined by (amongst other things) the amount to be traded, and the various tier limits; when the user changes the amount, then the derivation manager will re-calculate the bid/ask amount. The fields within the trade model are made available to Derivation instances using a module:caplin/trading/trademodel/DataHolder, an object that stores all the fields held within the trade model.

Methods

getDerivedFields() → {Array}

Returns the list of fields that this derivation will provide.

These fields may be required as input fields to another derivation, and will be appended to the data-holder when module:caplin/trading/derivation/Derivation#recalculateDerivedFields is called.

Returns:
A list of derived field names as strings.
Type
Array

getInputFields() → {Array}

Returns the list of fields that are required to perform the derivation.

The input fields of one derivation may be the derived fields of another derivation, and so will determine the order in which the derivations will be performed.

Returns:
A list of input field names as strings.
Type
Array

recalculateDerivedFields(oDataHolder)

Allows the derivation to recalculate the derived fields using the supplied trade data as input.

Derivations must be designed not to throw exceptions; in general, recalculation of the derived fields can occur due to a wide range of stimuli, and therefore exception handling would be dispersed and difficult to manage.

Parameters:
Name Type Description
oDataHolder module:caplin/trading/trademodel/DataHolder The trade data to be updated.