Interface TradeListener


  • public interface TradeListener
    Used to receive TradeEvents from the system.

    A TradeListener is tied to a Trade and is notified of new TradeEvents related to that Trade. A TradeListener typically listens to a single Trade, but the same TradeListener instance could also be set as the TradeListener for multiple Trades.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void receiveEvent​(TradeEvent event)
      Called when an event is generated (usually as a result of a client action) that causes the Trade to transition from one state to another.
      void receiveInvalidFieldsEvent​(InvalidFieldsEvent event)
      A state transition defined in the trade model configuration can specify message fields that are relevant to that transition (see the document Caplin Trading: Trade Model Configuration XML Reference).
      void receiveInvalidTransitionEvent​(InvalidTransitionEvent event)
      Called when a client event would trigger an invalid state transition in the trade model (that is, the triggering event is not valid for the current state of the trade model, or the trade model state requires that the event originates from the server, not the client).
    • Method Detail

      • receiveEvent

        void receiveEvent​(TradeEvent event)
                   throws TradeException

        Called when an event is generated (usually as a result of a client action) that causes the Trade to transition from one state to another. Subsequent events will not update fields on the associated Trade until the calling thread has returned from this method.

        Parameters:
        event - The TradeEvent that has been generated to cause this state transition.
        Throws:
        TradeException - Thrown if the TradeEvent cannot be handled.
      • receiveInvalidTransitionEvent

        void receiveInvalidTransitionEvent​(InvalidTransitionEvent event)

        Called when a client event would trigger an invalid state transition in the trade model (that is, the triggering event is not valid for the current state of the trade model, or the trade model state requires that the event originates from the server, not the client). This situation can occur when messages cross on the wire.

        When this callback is invoked, the trade model state will not have changed since the last valid event was received. Subsequent events will not update fields on the associated Trade until the calling thread has returned from this method.

        Parameters:
        event - The InvalidTransitionEvent containing the invalid TradeEvent and an error message.
      • receiveInvalidFieldsEvent

        void receiveInvalidFieldsEvent​(InvalidFieldsEvent event)

        A state transition defined in the trade model configuration can specify message fields that are relevant to that transition (see the document Caplin Trading: Trade Model Configuration XML Reference). When at run-time a client event is received, the Trading library checks the fields in the message against the fields specified in the trade model. An example of an error would be when the configuration specifies that a particular field is required but that field is not present in the message received from the client.

        When this callback is invoked, the trade model state will not have changed since the last valid event was received. Subsequent events will not update fields on the associated Trade until the calling thread has returned from this method.

        Parameters:
        event - The InvalidFieldsEvent containing the invalid TradeEvent a set of invalid fields and an error message.