public interface TradingApplicationListener
TradeChannel
and
BlotterChannel
lifecycle events.
Users' trading channels are represented by TradeChannels. Typically a user has a single TradeChannel to perform multiple Trades (though it is possible to configure different trade channels to be used by the same user, for example to split asset classes or trade categories, if desired). The TradingApplicationListener is notified when a new TradeChannel is created and when a TradeChannel is closed.
Users' blotter messaging channels are represented by BlotterChannels. A blotter channel is created when a
user opens a blotter on the client. The channelCreated(TradeChannel)
method will be called, and this call
should be used to communicate with an external system to retrieve / register for trade history information.
If you wish to receive auto-generated BlotterEvents containing notifications of trade lifecycle events, this is also
the point at which you should register a BlotterTradeListener
with the TradingProvider.addBlotterTradeListener(BlotterChannel, BlotterTradeListener)
method.
Modifier and Type | Method and Description |
---|---|
void |
blotterChannelClosed(BlotterChannel blotterChannel)
Called when a BlotterChannel is closed as a result of a user no longer being interested in this
particular blotter configuration or the connection being lost to the Liberator.
|
void |
blotterChannelCreated(BlotterChannel blotterChannel)
Called when a BlotterChannel is created as a result of a user requesting a blotter subject.
|
void |
channelClosed(TradeChannel channel)
Called when a channel is closed as a result of the user finishing its trading session or the connection
being lost to the Liberator.
|
void |
channelCreated(TradeChannel channel)
Called when a client wants to open a trading channel that will subsequently be used to perform
trades.
|
void |
peerDown(int peerIndex)
Called when a peer connection is lost.
|
void |
peerUp(int peerIndex)
Called when a peer connection is established.
|
void channelCreated(TradeChannel channel) throws TradeException
channel
- A trade channel that represents a particular user's session with the
TradingDataSource.TradeException
- Thrown if it is not possible to accept this trade channel, or the associated user.void channelClosed(TradeChannel channel)
channel
- The TradeChannel.void blotterChannelCreated(BlotterChannel blotterChannel)
The example singleton can be used to generate automatic blotter messages
from Trade events, by registering an instance of it with the TradingDataSource using TradingProvider.addBlotterTradeListener(BlotterChannel, BlotterTradeListener)
within this callback.
Example implementation:
... public void blotterChannelCreated( BlotterChannel blotterChannel ) { // request from backend system some historic trade information (using an example // class "HistoricalTrade" that comes from the Trading System HistoricTrade[] historicTrades = tradingSystem.getHistoricTrades(blotterChannel.getUserName()); sendHistoricTrades(blotterChannel, historicTrades); // also register for automatic blotter events for TradingDataSource managed trades tradingDataSource.addBlotterTradeListener(blotterChannel, AutoBlotterTradeListener.getInstance()); } private void sendHistoricTrades(BlotterChannel blotterChannel, HistoricTrades[] historicTrades) { for (trade : historicTrades) { BlotterMessage blotterMessage = blotterChannel.createBlotterMessage(); // for each field in the blotter (these are just examples of the fields that may be present on // the class "HistoricTrade" blotterMessage.addField("TradeID", trade.getId()); blotterMessage.addField("L1_Price", trade.getExecutedPrice()); blotterMessage.addField("Status", trade.getStatus()); // etc. // send the blotter message blotterChannel.sendBlotterMessage(blotterMessage); } } ... |
blotterChannel
- The BlotterChannel.TradingProvider.addBlotterTradeListener(BlotterChannel, BlotterTradeListener)
,
BlotterTradeListener
void blotterChannelClosed(BlotterChannel blotterChannel)
blotterChannel
- The BlotterChannel.void peerUp(int peerIndex)
This can be either the an initial peer connection
after startup or a re-established connection following a peerDown(int)
call.
peerIndex
- the index of the peer that has just connected. This is a 0 indexed id based on
the peer configuration order.void peerDown(int peerIndex)
This indicates that the connection to the remote peer (usually a Liberator) has been lost.
Currently this should be treated as a catastrophic event for all open TradeChannels and Trades,
and as such the upstream system should be notified of errors. Future version of the
TradingDataSource will provide the ability to re-establish in-progress Trades (and associated channels).
The behaviour after a connection lost is that this call will be followed by calls to
channelClosed(TradeChannel)
for any active TradeChannels for the peer.
peerIndex
- the index of the peer that has just disconnected. This is a 0 indexed id based on
the peer configuration order.Please send bug reports and comments to Caplin support