Namespace: caplin/trading

caplin/trading

A simple, event based messaging API for communicating domain specific trade events. Whip up a components' trade workflow using intelligible trade models

Every Trade must be constructed with a module:caplin/trading/statemachine/StateMachine which defines which states are available for that type of trade, and the transitions that are possible between the states. The StateMachine is created from an XML definition that is shared with a Trading DataSource. The following code snippet demonstrates how the state machines are loaded:

var oStateMachineFactory = new caplin.trading.statemachine.StateMachineFactory();
oStateMachineFactory.loadModels("conf/FxStateModel.xml");
oStateMachineFactory.loadModels("conf/FiStateModel.xml");
Trade Legs and Locking

As creation and deletion of trade legs can occur on both the client and server, it's important to note the possibility that simultaneous operations may occur on the same leg. For example, both the client and server may attempt to delete the same leg. To overcome this, a simple locking mechanism should be implemented so that only the client or server can perform add/remove operations at one time. This can easily be achieved by implementing a "Lock" transition in your state model, where a transition back to the current state occurs to signify to the other party that it should prevent any operations until an "Unlock" transition occurs.