Interface OrderChangeStateTradeListener


  • public interface OrderChangeStateTradeListener
    Used to receive TradeEvents from the system for OrderChangeState trades.

    The {OrderChangeState}TradeListener is tied to the OrderChangeStateTrade 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 Default Methods 
      Modifier and Type Method Description
      void onCancelWait​(@NotNull CancelWaitTradeEvent 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 onChangeState​(@NotNull ChangeStateTradeEvent 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.
      default void onError​(@NotNull com.caplin.trading.TradeEvent ev, @NotNull Throwable t)
      Optional callback for when an exception is caught while processing an event.
      void onTradeClosed()
      Callback for when the trade channel is closed
      default void onUnhandledTradeEvent​(@NotNull OrderChangeStateTrade trade, @NotNull com.caplin.trading.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.
      default void receiveInvalidFieldsEvent​(@NotNull com.caplin.trading.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).
      default void receiveInvalidTransitionEvent​(@NotNull com.caplin.trading.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

      • onChangeState

        void onChangeState​(@NotNull
                           @NotNull ChangeStateTradeEvent 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. 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.
      • onCancelWait

        void onCancelWait​(@NotNull
                          @NotNull CancelWaitTradeEvent 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. 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.
      • onUnhandledTradeEvent

        default void onUnhandledTradeEvent​(@NotNull
                                           @NotNull OrderChangeStateTrade trade,
                                           @NotNull
                                           @NotNull com.caplin.trading.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. This event is an additional event not included by default in the FX API spec, and thus delegated to this method. Subsequent events will not update fields on the associated Trade until the calling thread has returned from this method.

        Parameters:
        trade - The trade to transition
        event - The TradeEvent that has been generated to cause this state transition.
      • receiveInvalidTransitionEvent

        default void receiveInvalidTransitionEvent​(@NotNull
                                                   @NotNull com.caplin.trading.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

        default void receiveInvalidFieldsEvent​(@NotNull
                                               @NotNull com.caplin.trading.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.
      • onTradeClosed

        void onTradeClosed()
        Callback for when the trade channel is closed
      • onError

        default void onError​(@NotNull
                             @NotNull com.caplin.trading.TradeEvent ev,
                             @NotNull
                             @NotNull Throwable t)
        Optional callback for when an exception is caught while processing an event.
        Parameters:
        ev - The trade event that caused the exception to be thrown.
        t - The exception that was thrown.