Caplin Trader 5.0.0

Interface: module:ct-trading/trademodel/TradeFactory

module:ct-trading/trademodel/TradeFactory

This is in beta and therefore subject to API changes.

The TradeFactory interface should be implemented by objects that create module:ct-trading/trademodel/Trade objects.

The trade factory is used to create fresh module:ct-trading/trademodel/Trade objects, or to restore trade objects based on the contents of a Map. It also informs any module:ct-trading/trademodel/TradeFactoryListener registered via module:ct-trading/trademodel/TradeFactory#addListener whenever it creates a new trade.

Methods

createNewTrade(mTradeFields)

Create a Trade object for a new trade.

Parameters:
Name Type Description
mTradeFields Map

The map of fields required to create a trade. This should at least include AssetClass (e.g "FX"), TradingProtocol (e.g "RFS") and InstrumentName (e.g "/FX/GBPUSD").

restoreExistingTrade(oTrade, mFieldMap)

Restores a trade that is currently known on the client.

Parameters:
Name Type Description
oTrade module:ct-trading/trademodel/Trade

The trade object to restore.

mFieldMap Map

The trade data to restore the trade with.

restoreNewTrade(mFieldMap) → {module:ct-trading/trademodel/Trade}

Restores a trade that is not known on the client, then returns the newly created trade.

Parameters:
Name Type Description
mFieldMap Map

The data to restore the trade with.

Returns:

The newly created trade.

Type
module:ct-trading/trademodel/Trade