Interface TradeEvent

  • All Known Subinterfaces:
    TradeErrorEvent

    public interface TradeEvent

    A single event acting on a Trade.

    The event may be client generated and received through the TradeListener interface or it may be generated by custom code to be sent to the client using the Trade.sendEvent(TradeEvent) method.

    A TradeEvent is created using the Trade it relates to by calling the Trade.createEvent(String) method of the appropriate Trade instance.

    A TradeEvent typically represents a message received from the client or sent by the server. A message contains a set of fields and values which can be accessed using the getFields() method.

    A Typical message represented by a TradeEvent might be:

    Field Value
    MsgType Execute
    MsgVersion 5
    RequestId 123
    TradeId 456789
    PriceVersion 3
    BuySell BUY
    Price 1.9950
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addField​(java.lang.String name, int value)
      Adds a field to this TradeEvent.
      void addField​(java.lang.String name, java.lang.String value)
      Adds a field to this TradeEvent.
      void addLegAction​(LegAction action)
      Adds a leg action to the trade.
      EventSource getEventSource()
      Returns the source of this event: CLIENT, SERVER, or RESTORE
      java.lang.String getField​(java.lang.String name)
      Gets the value of a field in this TradeEvent.
      java.util.Map<java.lang.String,​java.lang.String> getFields()
      Gets the fields of this TradeEvent as a Map
      java.util.List<LegAction> getLegActions()
      Gets the leg actions associated with this event.
      java.lang.String getSource()
      Gets the source of this TradeEvent.
      Trade getTrade()
      Gets the Trade object that this TradeEvent belongs to.
      java.lang.String getType()
      Gets the type of the TradeEvent.
      boolean isType​(java.lang.String type)
      Confirms that the TradeEvent is of a certain type
      void setInitialTimestamp​(java.util.Date date)
      Sets LTY_INIT_TS field to this TradeEvent.
      void setRestorationId​(java.lang.String restorationId)
      Sets an id that will identify a trade restoration message.
    • Method Detail

      • getType

        java.lang.String getType()
        Gets the type of the TradeEvent.
        Returns:
        The type of this event.
      • isType

        boolean isType​(java.lang.String type)
        Confirms that the TradeEvent is of a certain type
        Parameters:
        type - The trade type to check.
        Returns:
        True if the requested type matches the TradeEvent type.
      • getTrade

        Trade getTrade()
        Gets the Trade object that this TradeEvent belongs to. As long as your code executes on the thread in which TradeListener.receiveEvent(TradeEvent) was called, the Trade's fields will not be updated by subsequent events, though its state may change.
        Returns:
        The Trade object.
      • getSource

        java.lang.String getSource()
        Gets the source of this TradeEvent.
        Returns:
        The name of the source of this TradeEvent.
      • setRestorationId

        void setRestorationId​(java.lang.String restorationId)
        Sets an id that will identify a trade restoration message. A restoration id should be supplied for the first TradeEvent on a client opened trade. This identifier should be retreived from the system that the Trading DataSource is integrating with.
        Parameters:
        restorationId - the system identifier for the trade.
        See Also:
        TradeChannel.setTradeChannelListener(TradeChannelListener), Trade.createRestoreEvent(String)
      • addField

        void addField​(java.lang.String name,
                      java.lang.String value)
        Adds a field to this TradeEvent.
        Parameters:
        name - The name of the field to add.
        value - The value of the field to add.
      • addField

        void addField​(java.lang.String name,
                      int value)
        Adds a field to this TradeEvent.
        Parameters:
        name - The name of the field to add.
        value - The value of the field to add.
      • setInitialTimestamp

        void setInitialTimestamp​(java.util.Date date)
        Sets LTY_INIT_TS field to this TradeEvent.
        Parameters:
        date - The time the LTY_INIT_TS field will be set to.
      • getField

        java.lang.String getField​(java.lang.String name)
        Gets the value of a field in this TradeEvent.
        Parameters:
        name - The name of the field.
        Returns:
        The value of the named field.
      • addLegAction

        void addLegAction​(LegAction action)
        Adds a leg action to the trade. This method is typically used when leg changes need to be made from the server side.
        Parameters:
        action - The leg action.
      • getLegActions

        java.util.List<LegAction> getLegActions()
        Gets the leg actions associated with this event. This method is typically used when the server receives a trade event from the client using the TradeListener interface and needs to determine what leg actions the client has performed on the trade.
        Returns:
        A list of leg actions.
      • getFields

        java.util.Map<java.lang.String,​java.lang.String> getFields()
        Gets the fields of this TradeEvent as a Map
        Returns:
        a map of the fields;
      • getEventSource

        EventSource getEventSource()
        Returns the source of this event: CLIENT, SERVER, or RESTORE
        Returns:
        a map of the fields;