Caplin Trader 5.1.0

Interface: module:ct-trading/trademodel/TradeLegFactory

module:ct-trading/trademodel/TradeLegFactory

The TradeLegFactory class is responsible for creating the correct instance of module:ct-trading/trademodel/TradeLeg, based on a given asset class. For example, within the reference implementation, instances of module:ct-fx/trademodel/FxTrade are constructed each time a trade leg is needed with an FX asset class.

This factory needs to exist so that functionality within the module:ct-trading/trademodel/Trade base class is still able to construct leg instances, even though it can not be sure of the exact leg class to use, it not being aware of the sub-class that has been used to extend module:ct-trading/trademodel/Trade.

Methods

createLeg(sAssetClass, oTrade, nLegId)

Creates an instance of a TradeLeg

Parameters:
Name Type Description
sAssetClass String

The class of the asset traded by leg.

oTrade module:ct-trading/trademodel/TradeLeg

The trade that the leg is a part of.

nLegId int

An identifier for the leg to be created.

Returns:

an instance of TradeLeg.