Caplin Trader 4.7.1

Class: module:caplin/trading/service/TOBOUserServiceProvider

module:caplin/trading/service/TOBOUserServiceProvider

The TOBOUserServiceProvider class provides a implementation of the module:caplin/trading/service/TOBOUserService which uses the module:caplin/trading/service/TOBOUserPermissionServiceListener and the provided module:caplin/trading/service/TradePermissionService to get the permissions of the currently logged-in user, which users he can trade on behalf of, and which of there TOBO users' accounts can be used to this end.

The TOBOUserServiceProvider maintains a state consisting of the logged-in user's type (TRADER or SALES) selected TOBO user and account, and the list of available TOBO users and accounts for the selected TOBO user, if any. (SALES users are allowed to trade on behalf of other users whereas TRADER users are not.) This state is kept up-to-date by the permission listener. It also keeps track of the number of trades started by the logged-in user, locking all listeners if at least one trade is started.

The TOBOUserServiceProvider also acts as a module:caplin/trading/trademodel/TradeOnBehalfOfListener, suspending trading while TOBO user changes are occurring in the application.

Constructor

new module:caplin/trading/service/TOBOUserServiceProvider(oTradeOnBehalfOfopt)

Constructs an instance of TOBOUserServiceProvider.
Parameters:
Name Type Attributes Default Description
oTradeOnBehalfOf module:caplin/trading/trademodel/TradeOnBehalfOf <optional>
{module:caplin/trading/trademodel/TradeOnBehalfOf TradeOnBehalfOf} The trade-on-behalf-of object.
Implements:

Methods

addListener(oListener)

Add a listener to the TOBOUserServiceProvider to be notified of changes in the selected TOBO user, user type and account, the list of available TOBO users and accounts and the TOBO user service lock.
Parameters:
Name Type Description
oListener module:caplin/trading/service/TOBOUserServiceListener Listener object.
Implements:
See:

canPerformTrade() → {boolean}

Returns true if the logged-in user can trade on behalf of other users and has selected a TOBO user to trade on behalf of.
Implements:
See:
Returns:
Type
boolean

canTradeOnBehalfOf() → {boolean}

This method can be used to query whether the logged-in user can trade on behalf of other users.
Implements:
See:
Returns:
True if logged-in user can trade on behalf of other users.
Type
boolean

getAccount() → {String}

Returns the account of the currently selected TOBO user which is being used by the logged-in user.
Implements:
See:
Returns:
The account name.
Type
String

getTradeOnBehalfOfUser() → {String}

Returns the TOBO user whom the logged-in user is trading on behalf of.
Implements:
See:
Returns:
The current TOBO user's userName.
Type
String

getUserType() → {String}

Returns the type of the logged-in user.
Implements:
See:
Returns:
The current logged-in user's type.
Type
String

removeListener(oListener)

Remove a listener of the TOBOUserServiceProvider.
Parameters:
Name Type Description
oListener module:caplin/trading/service/TOBOUserServiceListener Listener object.
Implements:
See:

setAccount(sAccount)

Sets the current TOBO user's account to be used for trading by the logged-in user. module:caplin/trading/service/TOBOUserServiceListener#onTOBOAccountChanged is called on all the TOBOUserService's listeners.
Parameters:
Name Type Description
sAccount String The account name.
Implements:
See:

setTradeOnBehalfOfUser(sUser)

This method sets the TOBO user and updates the account list with the accounts available for the new TOBO user. module:caplin/trading/service/TOBOUserServiceListener#onTOBOUserChanged is called on all the TOBOUserService's listeners.
Parameters:
Name Type Description
sUser String The TOBO user's userName.
Implements:
See:

tradeFinished()

This method is called by the trading components. If the TOBOUserService detects that no more trades are executing, the module:caplin/trading/service/TOBOUserServiceListener#onLockChanged is called on all the TOBOUserService's listeners, enabling them to 'unlock' their behaviour.
Implements:
See:

tradeOnBehalfOfChangeFailed(sReason)

A pending 'trade on behalf of' change has failed, and any subsequent prices are from the old tier.
Parameters:
Name Type Description
sReason String A string description of the reason for failure.
Implements:

tradeOnBehalfOfChangeInitiated(sPermissionable)

A 'trade on behalf of' change has been initiated, and we are currently awaiting prices for the new tier. Any existing prices should be considered stale.
Parameters:
Name Type Description
sPermissionable String A string representing the permissionable item that we are going to 'trade on behalf of'.
Implements:

tradeOnBehalfOfUserChanged(sPermissionable)

A 'trade on behalf of' change has been completed, and any subsequent prices are from the new tier.
Parameters:
Name Type Description
sPermissionable String A string representing the permissionable item that we are now 'trading on behalf of'.
Implements:

tradeStarted()

This method is called by the trading components, triggering module:caplin/trading/service/TOBOUserServiceListener#onLockChanged on all the TOBOUserService's listeners, enabling them to 'lock' their behaviour.
Implements:
See: