Interface TradeChannel

All Superinterfaces:
Serializable

public interface TradeChannel extends Serializable
An open trade messaging communications channel with an end user.

The TradeChannel encapsulates a subscription by a client to the TradingDataSource. It provides a bi-directional channel allowing messages to be sent by both client and the TradingDataSource.

  • Method Details

    • getUser

      String getUser()
      Gets the username of the user represented by this channel
      Returns:
      The username.
    • sendSubjectStatus

      void sendSubjectStatus(String statusMessage, com.caplin.datasource.SubjectStatus subjectStatus)
      Send a status message via the underlying channel for the subject
      Parameters:
      statusMessage - the statusMessage to send
      subjectStatus - the subjectStatus to send
    • getName

      String getName()
      Gets the name of the channel
      Returns:
      The channel name.
    • getPeerIndex

      int getPeerIndex()
      Get the index of the peer connection that is managing this TradeChannel.
      Returns:
      the 0-based index of the peer that is managing this trade channel, based on configuration order.
    • setTradeChannelListener

      void setTradeChannelListener(TradeChannelListener listener)
      Sets the ChannelListener for this TradeChannel. The ChannelListener will be notified when new Trades are initiated by the client this TradeChannel represents. The ChannelListener will also be notified of closed Trades.
      Parameters:
      listener - The ChannelListener.
    • getTradeChannelListener

      TradeChannelListener getTradeChannelListener()
      Gets the ChannelListener that is set on this TradeChannel.
      Returns:
      the ChannelListener that is set on this channel, or null if no listener is set.
    • getTrade

      Trade getTrade(String requestId)
      Gets a Trade associated with this TradeChannel. A TradeChannel might contain a number of Trades concurrently being handled. This method allows a single Trade to be obtained referenced by its requestId.
      Parameters:
      requestId - The RequestId for the Trade.
      Returns:
      The Trade object.
    • getAllTrades

      List<Trade> getAllTrades()
      Gets all the trades that this channel is currently managing.
      Returns:
      a List containing all the currently active trades. This list is a copy of the trades at the time the call is made and there is no guarantee that the trades are still active when iterating over the list.
    • restoreTrade

      Trade restoreTrade(String assetClass, String tradeProtocol, String restorationId) throws TradeException

      Creates a trade object to faciliate restoration of a trade with a client. Once the trade has been created, a restore event should be created via an invocation to Trade.createRestoreEvent(String).

      To allow for trades to be restored on the client, TradeEvent.setRestorationId(String) should be invoked on the first message sent to the client when it opens a trade. If the connection between the client and the Trading DataSource is lost and then re-established, the client will be able to identify the trade restoration message via the restorationId passed as an argument to this method.

      Parameters:
      assetClass - The asset class of the trade, e.g FX or FI.
      tradeProtocol - The trade protocol. This must be the name of the state model.
      restorationId - The system identifier for the trade.
      Returns:
      The restored trade.
      Throws:
      TradeException - Thrown if the trade would be in an invalid state.
      See Also:
    • createTrade

      Trade createTrade(String tradingProtocol) throws TradeException
      Throws:
      TradeException