Constructor
new module:caplin/trading/trademodel/TradeFactoryRepository()
TradeFactoryRepository
with the specified arguments.
- Implements:
Methods
-
addListener()
-
- See:
-
- module:caplin/trading/trademodel/TradeFactory#addListener
-
getTradeFactory(mFieldMap) → {module:caplin/trading/trademodel/TradeFactory}
-
Gets a TradeFactory that can create a
module:caplin/trading/trademodel/Trade
for the given field map.For a TradeFactory to be returned one must have been registered with a map that has elements that match the parameter
mFieldMap
.The ordering of the elements within the map is not important. For example, if a TradeFactory is registered using
module:caplin/trading/trademodel/TradeFactoryRepository#registerTradeFactory
with the map:{ "TradeProtocol": "ESP", "AssetClass": "FX" }
And the
module:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
method is called with a map with the element order reversed the match will succeed and a TradeFactory will be returned.{ "AssetClass": "FX" "TradeProtocol": "ESP", }
In addition, the requirement is that all map elements from the registered map must be present in the field map. There is no requirement that the map passed to
module:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
cannot contain additional elements. For example, the following would also match because it contains "TradeProtocol" and "AssetClass" with the expected values:{ "Account": "AccountOne", "AssetClass": "FX" "BaseCurrency": "USD", "TradeProtocol": "ESP", "UserName": "Fred" }
It is possible to register multiple trade factory objects with maps that may match. In this scenario the factory that has been registered first will be retrieved bymodule:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
.Parameters:
Name Type Description mFieldMap
Map The map to be matched against maps registered with a TradeFactory. Returns:
A TradeFactory that can create amodule:caplin/trading/trademodel/Trade
for the given field map. -
registerTradeFactory(mFieldMap, oTradeFactory)
-
Creates an association between a
Map
and a TradeFactory. Trade factories can later be retrieved usingmodule:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
and are used in calls tomodule:caplin/trading/trademodel/TradeFactoryRepository#restoreExistingTrade
. It is possible to register multiple trade factory objects with maps that may match. In this scenario the factory that has been registered first will be retrieved bymodule:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
and used bymodule:caplin/trading/trademodel/TradeFactoryRepository#restoreExistingTrade
.Parameters:
Name Type Description mFieldMap
Map The field map to be used in matches following calls to module:caplin/trading/trademodel/TradeFactoryRepository#getTradeFactory
andmodule:caplin/trading/trademodel/TradeFactoryRepository#restoreExistingTrade
.oTradeFactory
module:caplin/trading/trademodel/TradeFactory The TradeFactory. -
restoreExistingTrade()