Class
caplin.trading.trademodel

TradeService

Constructor Summary

Attributes Name and Description
caplin.trading.trademodel.TradeService()

Constructs a new TradeService.

Method Summary

Attributes Name and Description
void addListener(caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener, Function (optional))

Register a listener to be informed of trade service events.

void addTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener)

Adds a TradeRestoredListener to this service to listen to trade restoration for trades that don't currently exist on the client.

Array getTrades(Function (optional))

Return all trades stored in the trade repository maintained by TradeService.

void registerTradeFactory(Map mFieldMap, caplin.trading.trademodel.TradeFactory oTradeFactory)

Registers a TradeFactory that will be used to create or restore trades when the the trade contains data that matches the criteria in the map provided.

void removeListener(caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener)

Remove a listener from being informed of trade service events.

void removeTrade(String sRequestID)

void removeTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener)

Removes a TradeRestoredListener from listening to newly restored trades.

Methods implemented from class caplin.trading.trademodel.TradeFactoryListener:
tradeCreated, tradeRemoved

Constructor Detail

caplin.trading.trademodel.TradeService()

Constructs a new TradeService. Behaves as both a factory and repository for trades. It delegates creation of trades to individual factories that are registered with this service.

Method Detail

void addListener(caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener, Function (optional))

Register a listener to be informed of trade service events.

Parameters
caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener The listener to be informed of the events.
Function (optional) oFilter The filter to be applied to the listener.

void addTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener)

Adds a TradeRestoredListener to this service to listen to trade restoration for trades that don't currently exist on the client. If the trade exists on the client, you should add the listener to the Trade object itself.

Parameters
caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener The listener to add.

Array getTrades(Function (optional))

Return all trades stored in the trade repository maintained by TradeService.

Parameters
Function (optional) oFilter allows filtering of returned trades
Returns
{Array} A list of trades accepted by the filter, or all trades if no filter is provided.

void registerTradeFactory(Map mFieldMap, caplin.trading.trademodel.TradeFactory oTradeFactory)

Registers a TradeFactory that will be used to create or restore trades when the the trade contains data that matches the criteria in the map provided. 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 used.

Parameters
Map mFieldMap The field map to be used to match trade data.
caplin.trading.trademodel.TradeFactory oTradeFactory The TradeFactory.

void removeListener(caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener)

Remove a listener from being informed of trade service events.

Parameters
caplin.trading.trademodel.TradeFactoryListener oTradeFactoryListener The listener to be removed.

void removeTrade(String sRequestID)

Parameters
String sRequestID Remove completed trade from the service.

void removeTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener)

Removes a TradeRestoredListener from listening to newly restored trades.

Parameters
caplin.trading.restoration.TradeRestoredListener oTradeRestoredListener The listener to remove.