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 void
addHandler(MamdaOrderBookHandler handler)
Add a specialized order book handler.void
addIgnoreEntryId(java.lang.String id)
Add an entry ID to ignore.void
clear()
Clear all cached data fields.com.wombat.mama.MamaDateTime
getActivityTime()
Activity time.short
getActivityTimeFieldState()
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 updatedlong
getBeginGapSeqNum()
Beginning sequence number in a detected gap event.MamdaOrderBook
getBookSnapshot()
Returns a deep, writeable copy of the underlying order book.static MamdaOrderBook
getBookSnapShot(java.lang.String symbol)
long
getEndGapSeqNum()
Ending sequence number in a detected gap event.long
getEventSeqNum()
short
getEventSeqNumFieldState()
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.MamaDateTime
getEventTime()
short
getEventTimeFieldState()
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.MamaDateTime
getLineTime()
Get the line time of the update.short
getLineTimeFieldState()
short
getMsgQual()
MamdaOrderBook
getOrderBook()
Returns the full orderbook related to this clear event.java.lang.String
getPartId()
Get the participant identifier.short
getPartIdFieldState()
boolean
getProcessMarketOrders()
MamdaOrderBook
getReadOnlyBookSnapshot()
Returns a deep, read only, copy of the underlying order book.com.wombat.mama.MamaDateTime
getSendTime()
Get the send time of the update.short
getSendTimeFieldState()
com.wombat.mama.MamaDateTime
getSrcTime()
Source time.short
getSrcTimeFieldState()
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.String
getSymbol()
Get the string symbol for the instrument.short
getSymbolFieldState()
void
onMsg(MamdaSubscription subscription, com.wombat.mama.MamaMsg msg, short msgType)
Implementation of MamdaListener interface.void
removeIgnoreEntryId(java.lang.String id)
Remove an entry ID to ignore.void
setProcessEntries(boolean process)
Set whether we are interested in "entry level" information at all.void
setProcessMarketOrders(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:MamdaBasicRecap
Get the string symbol for the instrument.- Specified by:
getSymbol
in 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:MamdaBasicRecap
Get the participant identifier.- Specified by:
getPartId
in 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:MamdaBasicRecap
Source time. Typically, the exchange generated feed- Specified by:
getSrcTime
in interfaceMamdaBasicEvent
- Specified by:
getSrcTime
in 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:MamdaBasicRecap
Activity time. A feed handler generated time stamp representing when the data item was last updated.- Specified by:
getActivityTime
in interfaceMamdaBasicEvent
- Specified by:
getActivityTime
in interfaceMamdaBasicRecap
- 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 interfaceMamdaBasicEvent
- Returns:
- Source sequence number. The exchange generated sequence number.
-
getEventTime
public com.wombat.mama.MamaDateTime getEventTime()
- Specified by:
getEventTime
in 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:MamdaBasicRecap
Get the line time of the update.- Specified by:
getLineTime
in 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:MamdaBasicRecap
Get the send time of the update.- Specified by:
getSendTime
in 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:MamdaOrderBookClear
Returns the full orderbook related to this clear event.- Specified by:
getOrderBook
in interfaceMamdaOrderBookClear
- Specified by:
getOrderBook
in interfaceMamdaOrderBookRecap
- Returns:
- The full order book.
-
getBeginGapSeqNum
public long getBeginGapSeqNum()
Description copied from interface:MamdaOrderBookGap
Beginning sequence number in a detected gap event.- Specified by:
getBeginGapSeqNum
in interfaceMamdaOrderBookGap
-
getEndGapSeqNum
public long getEndGapSeqNum()
Description copied from interface:MamdaOrderBookGap
Ending sequence number in a detected gap event.- Specified by:
getEndGapSeqNum
in interfaceMamdaOrderBookGap
-
setProcessMarketOrders
public void setProcessMarketOrders(boolean process)
-
getProcessMarketOrders
public boolean getProcessMarketOrders()
-
getSymbolFieldState
public short getSymbolFieldState()
- Specified by:
getSymbolFieldState
in interfaceMamdaBasicRecap
- Returns:
- symbol Field State
-
getPartIdFieldState
public short getPartIdFieldState()
- Specified by:
getPartIdFieldState
in interfaceMamdaBasicRecap
- Returns:
- participant ID Field State
-
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 interfaceMamdaBasicEvent
- Specified by:
getSrcTimeFieldState
in interfaceMamdaBasicRecap
- 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 interfaceMamdaBasicEvent
- Specified by:
getActivityTimeFieldState
in interfaceMamdaBasicRecap
- Returns:
- activity time Field State
-
getLineTimeFieldState
public short getLineTimeFieldState()
- Specified by:
getLineTimeFieldState
in interfaceMamdaBasicRecap
- Returns:
- line time Field State
-
getSendTimeFieldState
public short getSendTimeFieldState()
- Specified by:
getSendTimeFieldState
in interfaceMamdaBasicRecap
- Returns:
- send 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 interfaceMamdaBasicEvent
-
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 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:
onMsg
in 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.
-
-