Package com.wombat.mamda.orderbook
Class MamdaOrderBookListener
- java.lang.Object
-
- com.wombat.mamda.orderbook.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 Summary
Constructors Constructor Description MamdaOrderBookListener()Create an order book listener using internally created data structures for the full and delta order books.MamdaOrderBookListener(MamdaOrderBook fullBook)Create an order book listener using an optional user-provided object for the full order book.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddHandler(MamdaOrderBookHandler handler)Add a specialized order book handler.voidaddIgnoreEntryId(java.lang.String id)Add an entry ID to ignore.voidclear()Clear all cached data fields.com.wombat.mama.MamaDateTimegetActivityTime()Activity time.shortgetActivityTimeFieldState()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 updatedlonggetBeginGapSeqNum()Beginning sequence number in a detected gap event.MamdaOrderBookgetBookSnapshot()Returns a deep, writeable copy of the underlying order book.static MamdaOrderBookgetBookSnapShot(java.lang.String symbol)longgetEndGapSeqNum()Ending sequence number in a detected gap event.longgetEventSeqNum()shortgetEventSeqNumFieldState()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 updatedcom.wombat.mama.MamaDateTimegetEventTime()shortgetEventTimeFieldState()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 updatedcom.wombat.mama.MamaDateTimegetLineTime()Get the line time of the update.shortgetLineTimeFieldState()shortgetMsgQual()MamdaOrderBookgetOrderBook()Returns the full orderbook related to this clear event.java.lang.StringgetPartId()Get the participant identifier.shortgetPartIdFieldState()booleangetProcessMarketOrders()MamdaOrderBookgetReadOnlyBookSnapshot()Returns a deep, read only, copy of the underlying order book.com.wombat.mama.MamaDateTimegetSendTime()Get the send time of the update.shortgetSendTimeFieldState()com.wombat.mama.MamaDateTimegetSrcTime()Source time.shortgetSrcTimeFieldState()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 updatedjava.lang.StringgetSymbol()Get the string symbol for the instrument.shortgetSymbolFieldState()voidonMsg(MamdaSubscription subscription, com.wombat.mama.MamaMsg msg, short msgType)Implementation of MamdaListener interface.voidremoveIgnoreEntryId(java.lang.String id)Remove an entry ID to ignore.voidsetProcessEntries(boolean process)Set whether we are interested in "entry level" information at all.voidsetProcessMarketOrders(boolean process)
-
-
-
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:MamdaBasicRecapGet the string symbol for the instrument.- Specified by:
getSymbolin interfaceMamdaBasicRecap- 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:MamdaBasicRecapGet the participant identifier.- Specified by:
getPartIdin interfaceMamdaBasicRecap- 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:MamdaBasicRecapSource time. Typically, the exchange generated feed- Specified by:
getSrcTimein interfaceMamdaBasicEvent- Specified by:
getSrcTimein interfaceMamdaBasicRecap- 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:MamdaBasicRecapActivity time. A feed handler generated time stamp representing when the data item was last updated.- Specified by:
getActivityTimein interfaceMamdaBasicEvent- Specified by:
getActivityTimein interfaceMamdaBasicRecap- Returns:
- Activity time. A feed handler generated time stamp representing when the data item was last updated.
-
getEventSeqNum
public long getEventSeqNum()
- Specified by:
getEventSeqNumin interfaceMamdaBasicEvent- Returns:
- Source sequence number. The exchange generated sequence number.
-
getEventTime
public com.wombat.mama.MamaDateTime getEventTime()
- Specified by:
getEventTimein interfaceMamdaBasicEvent- 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:MamdaBasicRecapGet the line time of the update.- Specified by:
getLineTimein interfaceMamdaBasicRecap- 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:MamdaBasicRecapGet the send time of the update.- Specified by:
getSendTimein interfaceMamdaBasicRecap- 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()
-
getOrderBook
public MamdaOrderBook getOrderBook()
Description copied from interface:MamdaOrderBookClearReturns the full orderbook related to this clear event.- Specified by:
getOrderBookin interfaceMamdaOrderBookClear- Specified by:
getOrderBookin interfaceMamdaOrderBookRecap- Returns:
- The full order book.
-
getBeginGapSeqNum
public long getBeginGapSeqNum()
Description copied from interface:MamdaOrderBookGapBeginning sequence number in a detected gap event.- Specified by:
getBeginGapSeqNumin interfaceMamdaOrderBookGap
-
getEndGapSeqNum
public long getEndGapSeqNum()
Description copied from interface:MamdaOrderBookGapEnding sequence number in a detected gap event.- Specified by:
getEndGapSeqNumin interfaceMamdaOrderBookGap
-
setProcessMarketOrders
public void setProcessMarketOrders(boolean process)
-
getProcessMarketOrders
public boolean getProcessMarketOrders()
-
getSymbolFieldState
public short getSymbolFieldState()
- Specified by:
getSymbolFieldStatein interfaceMamdaBasicRecap- Returns:
- symbol Field State
-
getPartIdFieldState
public short getPartIdFieldState()
- Specified by:
getPartIdFieldStatein interfaceMamdaBasicRecap- Returns:
- participant ID Field State
-
getSrcTimeFieldState
public short getSrcTimeFieldState()
Description copied from interface:MamdaBasicEventreturn 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:
getSrcTimeFieldStatein interfaceMamdaBasicEvent- Specified by:
getSrcTimeFieldStatein interfaceMamdaBasicRecap- Returns:
- source time Field State
-
getActivityTimeFieldState
public short getActivityTimeFieldState()
Description copied from interface:MamdaBasicEventreturn 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:
getActivityTimeFieldStatein interfaceMamdaBasicEvent- Specified by:
getActivityTimeFieldStatein interfaceMamdaBasicRecap- Returns:
- activity time Field State
-
getLineTimeFieldState
public short getLineTimeFieldState()
- Specified by:
getLineTimeFieldStatein interfaceMamdaBasicRecap- Returns:
- line time Field State
-
getSendTimeFieldState
public short getSendTimeFieldState()
- Specified by:
getSendTimeFieldStatein interfaceMamdaBasicRecap- Returns:
- send time Field State
-
getEventTimeFieldState
public short getEventTimeFieldState()
Description copied from interface:MamdaBasicEventreturn 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:
getEventTimeFieldStatein interfaceMamdaBasicEvent
-
getEventSeqNumFieldState
public short getEventSeqNumFieldState()
Description copied from interface:MamdaBasicEventreturn 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:
getEventSeqNumFieldStatein interfaceMamdaBasicEvent
-
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:
onMsgin interfaceMamdaMsgListener- 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.
-
-