Class
caplin.trading.service

WorkbenchTradeService

This service is meant to be used to configure the desired server events which will be used to feed the caplin.trading.workbench.TradeStateVisualiser. The alias for this service is caplin.workbench-trade-service.

Keep in mind that this service listens to trade creations (via the trade service) so it is recommended to configure it before any call to the create trades on the trade service has been made.


This is how you will configure it:
var oWorkbenchTradeService = caplin.core.ServiceRegistry.getService("caplin.workbench-trade-service");
oWorkbenchTradeService.setServerDataForTransition("RFS","OpenAck", {"TradeID": "1234567"});
oWorkbenchTradeService.setAutoServerEvents("RFS",["OpenAck", "PriceUpdate", "Execute", "ExecuteAck", "TradeConfirmation"]);

Constructor Summary

Attributes Name and Description
caplin.trading.service.WorkbenchTradeService()

Method Summary

Attributes Name and Description
void addServerDataListeners( fServerDataForTransitionCallback, fAutoServerEventsCallback)

Allows the registration of server data changes listeners.

void addTradeListeners( fTradeCreatedCallback, fTradeRemovedCallback)

Allows the registration of trade creation and trade removal listeners.

Map getAutoServerEvents(String sRequestID)

Returns the server events for a given trade.

Map getServerDataForTransitions(String sRequestID)

Returns the transition server data for a given trade.

caplin.trading.workbench.model.StateMachineMonitor getStateMonitor(String sRequestID)

Returns the state monitor associated to a trade.

Array getTrades()

Returns the trades contained within the trade service.

void setAutoServerEvents(Array pServerEvents, pAutoServerTransitions)

Define which will be the events that will automatically be served.

void setServerDataForTransition(String sTransitionName, Map mData, mTransitionData)

Defines the data that is needed for the server transitions received by the caplin.trading.trademodel.TradeMessageService when 'auto server data' switch is on.

void tradeCreated( oTradeFactory, oTrade)

void tradeRemoved( oTradeFactory, sRequestID)

Constructor Detail

caplin.trading.service.WorkbenchTradeService()

Method Detail

void addServerDataListeners( fServerDataForTransitionCallback, fAutoServerEventsCallback)

Allows the registration of server data changes listeners. Callbacks registered will be triggered whenever there is a change on the server data.

Parameters
fServerDataForTransitionCallback
fAutoServerEventsCallback

void addTradeListeners( fTradeCreatedCallback, fTradeRemovedCallback)

Allows the registration of trade creation and trade removal listeners. Callbacks registered will be triggered whenever a trade gets either added or removed.

Parameters
fTradeCreatedCallback
fTradeRemovedCallback

Map getAutoServerEvents(String sRequestID)

Returns the server events for a given trade.

Parameters
String sRequestID id identifying a trade.
Returns
{Map}

Map getServerDataForTransitions(String sRequestID)

Returns the transition server data for a given trade.

Parameters
String sRequestID id identifying a trade.
Returns
{Map}

caplin.trading.workbench.model.StateMachineMonitor getStateMonitor(String sRequestID)

Returns the state monitor associated to a trade.

Parameters
String sRequestID id identifying a trade.
Returns
{caplin.trading.workbench.model.StateMachineMonitor}

Array getTrades()

Returns the trades contained within the trade service.

Returns
{Array}

void setAutoServerEvents(Array pServerEvents, pAutoServerTransitions)

Define which will be the events that will automatically be served.

Parameters
Array pServerEvents The array of events that will be served in case no user interaction is selected.
pAutoServerTransitions

void setServerDataForTransition(String sTransitionName, Map mData, mTransitionData)

Defines the data that is needed for the server transitions received by the caplin.trading.trademodel.TradeMessageService when 'auto server data' switch is on. If is is off, the data will be selected by the user.

Parameters
String sTransitionName The transition name
Map mData Map with the data the transition will generate
mTransitionData

void tradeCreated( oTradeFactory, oTrade)

Parameters
oTradeFactory
oTrade
See
caplin.trading.trademodel.TradeFactoryListener#tradeCreated

void tradeRemoved( oTradeFactory, sRequestID)

Parameters
oTradeFactory
sRequestID
See
caplin.trading.trademodel.TradeFactoryListener#tradeRemoved