Class MamdaOrderBookListener

  • All Implemented Interfaces:
    MamdaBasicEvent, MamdaBasicRecap, MamdaMsgListener, MamdaOrderBookClear, MamdaOrderBookGap, MamdaOrderBookRecap

    public class MamdaOrderBookListener
    extends java.lang.Object
    implements MamdaMsgListener, MamdaOrderBookClear, MamdaOrderBookRecap, MamdaOrderBookGap
    MamdaOrderBookListener is a class that specializes in handling order book updates. Developers provide their own implementation of the MamdaOrderBookHandler interface and will be delivered notifications for order book recaps and deltas. Notifications for order book deltas include the delta itself as well as the full order book with deltas applied. An obvious application for this MAMDA class is any kind of program trading application that looks at depth of book. Note: The MamdaOrderBookListener class caches the order book. Among other reasons, caching of these fields makes it possible to provide complete trade-related callbacks, even when the publisher (e.g., feed handler) is only publishing deltas containing modified fields.
    • Constructor Detail

      • MamdaOrderBookListener

        public MamdaOrderBookListener()
        Create an order book listener using internally created data structures for the full and delta order books.
      • MamdaOrderBookListener

        public MamdaOrderBookListener​(MamdaOrderBook fullBook)
        Create an order book listener using an optional user-provided object for the full order book. If "fullBook" is NULL, an object will be allocated internally. If this listener is destroyed then the full order book object will only be destroyed if it was created by the listener (i.e., if fullBook was passed as NULL in this constructor).
        Parameters:
        fullBook - The MamdaOrderBook used to maintain the full book.
    • Method Detail

      • addHandler

        public void addHandler​(MamdaOrderBookHandler handler)
        Add a specialized order book handler. Currently, only one handler can (and must) be registered.
        Parameters:
        handler - The hadler registered to receive order book update callbacks.
      • addIgnoreEntryId

        public void addIgnoreEntryId​(java.lang.String id)
        Add an entry ID to ignore. This only makes sense when the entry type is participant ID (as opposed to order ID). All order book updates for this entry ID will be ignored.
        Parameters:
        id - The id of the participant to ignore when process book updates.
      • removeIgnoreEntryId

        public void removeIgnoreEntryId​(java.lang.String id)
        Remove an entry ID to ignore.
        Parameters:
        id - The id of the participant whose update will be subsequently processed as part of the book.
        See Also:
        addIgnoreEntryId(String)
      • clear

        public void clear()
        Clear all cached data fields.
      • getSymbol

        public java.lang.String getSymbol()
        Description copied from interface: MamdaBasicRecap
        Get the string symbol for the instrument.
        Specified by:
        getSymbol in interface MamdaBasicRecap
        Returns:
        Symbol. This is the "well-known" symbol for the security, including any symbology mapping performed by the publisher.
      • getPartId

        public java.lang.String getPartId()
        Description copied from interface: MamdaBasicRecap
        Get the participant identifier.
        Specified by:
        getPartId in interface MamdaBasicRecap
        Returns:
        Participant ID. This may be an exchange identifier, a market maker ID, etc., or NULL (if this is not related to any specific participant).
      • getSrcTime

        public com.wombat.mama.MamaDateTime getSrcTime()
        Description copied from interface: MamdaBasicRecap
        Source time. Typically, the exchange generated feed
        Specified by:
        getSrcTime in interface MamdaBasicEvent
        Specified by:
        getSrcTime in interface MamdaBasicRecap
        Returns:
        Source time. Typically, the exchange generated feed time stamp. This is often the same as the "event time", because many feeds do not distinguish between the actual event time and when the exchange sent the message.
      • getActivityTime

        public com.wombat.mama.MamaDateTime getActivityTime()
        Description copied from interface: MamdaBasicRecap
        Activity time. A feed handler generated time stamp representing when the data item was last updated.
        Specified by:
        getActivityTime in interface MamdaBasicEvent
        Specified by:
        getActivityTime in interface MamdaBasicRecap
        Returns:
        Activity time. A feed handler generated time stamp representing when the data item was last updated.
      • getEventSeqNum

        public long getEventSeqNum()
        Specified by:
        getEventSeqNum in interface MamdaBasicEvent
        Returns:
        Source sequence number. The exchange generated sequence number.
      • getEventTime

        public com.wombat.mama.MamaDateTime getEventTime()
        Specified by:
        getEventTime in interface MamdaBasicEvent
        Returns:
        Event time. Typically, when the event actually occurred. This is often the same as the "source time", because many feeds do not distinguish between the actual event time and when the exchange sent the message.
      • getLineTime

        public com.wombat.mama.MamaDateTime getLineTime()
        Description copied from interface: MamdaBasicRecap
        Get the line time of the update.
        Specified by:
        getLineTime in interface MamdaBasicRecap
        Returns:
        Line time. A feed handler (or similar publisher) time stamp representing the time that such publisher received the update message pertaining to the event. If clocks are properly synchronized and the source time (see above) is accurate enough, then the difference between the source time and line time is the latency between the data source and the feed handler.
      • getSendTime

        public com.wombat.mama.MamaDateTime getSendTime()
        Description copied from interface: MamdaBasicRecap
        Get the send time of the update.
        Specified by:
        getSendTime in interface MamdaBasicRecap
        Returns:
        Send time. A feed handler (or similar publisher) time stamp representing the time that such publisher sent the current message. The difference between the line time and send time is the latency within the feed handler itself. Also, if clocks are properly synchronized then the difference between the send time and current time is the latency within the market data distribution framework (i.e. MAMA and the underlying middleware).
      • getMsgQual

        public short getMsgQual()
      • setProcessMarketOrders

        public void setProcessMarketOrders​(boolean process)
      • getProcessMarketOrders

        public boolean getProcessMarketOrders()
      • getSrcTimeFieldState

        public short getSrcTimeFieldState()
        Description copied from interface: MamdaBasicEvent
        return Source time Field State MODIFIED (2) value indicates the fied was updated in last tick NOT MODIFIED (1) value indicate that there was no change in the last tick NOT_INITIALISED (0) value indicates that the field has never been updated
        Specified by:
        getSrcTimeFieldState in interface MamdaBasicEvent
        Specified by:
        getSrcTimeFieldState in interface MamdaBasicRecap
        Returns:
        source time Field State
      • getActivityTimeFieldState

        public short getActivityTimeFieldState()
        Description copied from interface: MamdaBasicEvent
        return Activity time Field State MODIFIED (2) value indicates the fied was updated in last tick NOT MODIFIED (1) value indicate that there was no change in the last tick NOT_INITIALISED (0) value indicates that the field has never been updated
        Specified by:
        getActivityTimeFieldState in interface MamdaBasicEvent
        Specified by:
        getActivityTimeFieldState in interface MamdaBasicRecap
        Returns:
        activity time Field State
      • getEventTimeFieldState

        public short getEventTimeFieldState()
        Description copied from interface: MamdaBasicEvent
        return event time Field State MODIFIED (2) value indicates the fied was updated in last tick NOT MODIFIED (1) value indicate that there was no change in the last tick NOT_INITIALISED (0) value indicates that the field has never been updated
        Specified by:
        getEventTimeFieldState in interface MamdaBasicEvent
      • getEventSeqNumFieldState

        public short getEventSeqNumFieldState()
        Description copied from interface: MamdaBasicEvent
        return source sequence number Field State MODIFIED (2) value indicates the fied was updated in last tick NOT MODIFIED (1) value indicate that there was no change in the last tick NOT_INITIALISED (0) value indicates that the field has never been updated
        Specified by:
        getEventSeqNumFieldState in interface MamdaBasicEvent
      • setProcessEntries

        public void setProcessEntries​(boolean process)
        Set whether we are interested in "entry level" information at all. Many applications only care about price level information. (Default is to process entry level information.)
        Parameters:
        process - Whether to process entries in books.
      • getBookSnapshot

        public MamdaOrderBook getBookSnapshot()
        Returns a deep, writeable copy of the underlying order book.
        Returns:
        A snapshot of the current Order Book
      • getBookSnapShot

        public static MamdaOrderBook getBookSnapShot​(java.lang.String symbol)
      • getReadOnlyBookSnapshot

        public MamdaOrderBook getReadOnlyBookSnapshot()
        Returns a deep, read only, copy of the underlying order book. This method is faster than the writeable getBookSnapshot.
        Returns:
        A deep snapshot of the current Order Book
      • onMsg

        public void onMsg​(MamdaSubscription subscription,
                          com.wombat.mama.MamaMsg msg,
                          short msgType)
        Implementation of MamdaListener interface.
        Specified by:
        onMsg in interface MamdaMsgListener
        Parameters:
        subscription - The MamdaSubscription to which this listener was registered.
        msg - The MamaMsg received by the underlying MAMA API and which resulted in this callback being invoked.
        msgType - The message type. e.g. INITIAL, RECAP, UPDATE etc.