Interface OrderSubmissionTradeListener


public interface OrderSubmissionTradeListener
Used to receive TradeEvents from the system for OrderSubmission trades.

The {OrderSubmission}TradeListener is tied to the OrderSubmissionTrade 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

    Modifier and Type
    Method
    Description
    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
    onSubmit(@NotNull SubmitTradeEvent 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
    Callback for when the trade channel is closed
    default void
    onUnhandledTradeEvent(@NotNull OrderSubmissionTrade 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 Details

    • onSubmit

      void onSubmit(@NotNull @NotNull SubmitTradeEvent 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 OrderSubmissionTrade 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.