Caplin Trader 4.7.1

Class: module:caplin/trading/trademodel/TradeOnBehalfOf



new module:caplin/trading/trademodel/TradeOnBehalfOf(oMessageService)

Is responsible for communicating with Liberator that the current user (generally a salesman or head trader) executes trades on behalf of another user (generally a client trader). When "trading on behalf of" the salesman needs to trade on the prices the trader would trade on if they were logged into the system themselves. Liberator does this by maintaining multiple prices (tiers) for each instrument (e.g. currency /FX/GBPUSD/T1 and /FX/GBPUSD/T2). Different users are mapped to different tiers. Usually liberator performs mapping based on the identity of the logged in user. When "trading on behalf of" Liberator uses the field "UserName" in a well know user subject to drive the mapping. This class simply contributes the userName to be traded on behalf of. When the contribution is successfully processed by Liberator it publishes the new tier prices to the Caplin Trader client. We must not allow the user to trade on old prices prior to the tier change. To change the mappings, Liberator invalidates the internal user session (this is not communicated to the client), any price received thereafter is guaranteed to be from the new tier. We therefore listen on the "/TOBOCHANGEUSER" subject, because changes to this are published to listeners AFTER the Liberator internal session invalidation. We then notify any listeners that any subsequent prices are valid from the new tier and trading may re-commence.
Name Type Description
oMessageService module:caplin/services/messaging/MessageService Message Service implementation.



Register a listener to be informed of "trade on behalf of" events.
Name Type Description
oTradeOnBehalfOfListener module:caplin/trading/trademodel/TradeOnBehalfOfListener The listener to be informed of the events.


Clears any current "trade on behalf of" settings, reverting back to the original user's prices .
Name Type Description
sNamespace String The namespace of the permissionable to clear.


Destructor method.

setTradeOnBehalfOfPermissionable(sNamespace, sPermissionable)

Initiate a trade on behalf of change, switching your application to display the prices for the specified permissionable item.
Name Type Description
sNamespace String The namespace within the /TOBOCHANGEUSER subject you want to contrib to. The value for this depends on what permissionable object you're changing to, e.g. UserName or Account.
sPermissionable String Identifier for the permissioned item you want to trade on behalf of. Typically this would be a username, however could be anything with permissions (e.g. accounts in some instances). Passing in a null value will clear any current "trade on behalf of" settings, as if the clearTradeOnBehalfOfPermissionable function had been called.