TradeService
behaves as both a factory and repository for trades. It delegates creation of trades
to individual factories that are registered with this service.
Attributes | Name and Description |
---|---|
|
caplin.trading.service.TradeService()
|
Attributes | Name and Description |
---|---|
|
void
addListener(caplin.trading.trademodel.TradeFactoryListener tradeFactoryListener, Function (optional))
Register a listener to be informed of trade service events. |
|
void
addTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener tradeRestoredListener)
Adds a TradeRestoredListener to this service to listen to trade restoration for trades that don't currently exist on the client. |
|
Array
getTrades(Function filter)
Return all trades stored in the trade repository maintained by TradeService. |
|
void
registerTradeFactory(Map fieldMap, caplin.trading.trademodel.TradeFactory tradeFactory)
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 tradeFactoryListener)
Remove a listener from being informed of trade service events. |
|
void
removeTrade(String cequestID)
Remove completed trade from the service. |
|
void
removeTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener tradeRestoredListener)
Removes a TradeRestoredListener from listening to newly restored trades. |
|
caplin.trading.trademodel.Trade
restoreExistingTrade(caplin.trading.trademodel.Trade trade, Map fieldMap)
Invoked from the TradeMessageService. |
|
caplin.trading.trademodel.Trade
restoreNewTrade(Map fieldMap)
Invoked from the TradeMessageService. |
►
caplin.trading.service.TradeService()
►
void
addListener(caplin.trading.trademodel.TradeFactoryListener tradeFactoryListener, Function (optional))
Register a listener to be informed of trade service events.
caplin.trading.trademodel.TradeFactoryListener | tradeFactoryListener | The listener to be informed of the events. |
Function | (optional) | filter allows filtering of returned trades. This function should take a {caplin.trading.trademodel.Trade} as its only argument, and should return true if the given Trade is accepted by the filter, and false otherwise. |
►
void
addTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener tradeRestoredListener)
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.
caplin.trading.restoration.TradeRestoredListener | tradeRestoredListener | The listener to add. |
►
Array
getTrades(Function filter)
Return all trades stored in the trade repository maintained by TradeService.
Function | filter | (Optional) Allows filtering of returned trades. This function should take a {caplin.trading.trademodel.Trade} as its only argument, and should return true if the given Trade is accepted by the filter, and false otherwise. |
►
void
registerTradeFactory(Map fieldMap, caplin.trading.trademodel.TradeFactory tradeFactory)
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.
Map | fieldMap | The field map to be used to match trade data. |
caplin.trading.trademodel.TradeFactory | tradeFactory | The TradeFactory. |
►
void
removeListener(caplin.trading.trademodel.TradeFactoryListener tradeFactoryListener)
Remove a listener from being informed of trade service events.
caplin.trading.trademodel.TradeFactoryListener | tradeFactoryListener | The listener to be removed. |
►
void
removeTrade(String cequestID)
Remove completed trade from the service.
String | cequestID |
►
void
removeTradeRestoredListener(caplin.trading.restoration.TradeRestoredListener tradeRestoredListener)
Removes a TradeRestoredListener from listening to newly restored trades.
caplin.trading.restoration.TradeRestoredListener | tradeRestoredListener | The listener to remove. |
►
caplin.trading.trademodel.Trade
restoreExistingTrade(caplin.trading.trademodel.Trade trade, Map fieldMap)
Invoked from the TradeMessageService.
caplin.trading.trademodel.Trade | trade | |
Map | fieldMap |
►
caplin.trading.trademodel.Trade
restoreNewTrade(Map fieldMap)
Invoked from the TradeMessageService.
Map | fieldMap |