Package com.wombat.mamda.orderbook
Class MamdaOrderBookPriceLevel
- java.lang.Object
-
- com.wombat.mamda.orderbook.MamdaOrderBookPriceLevel
-
public class MamdaOrderBookPriceLevel extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description static char
ACTION_ADD
static char
ACTION_DELETE
Updated price level.static char
ACTION_UNKNOWN
Deleted price level.static char
ACTION_UPDATE
A new price level.static char
LEVEL_LIMIT
Unknown side (error).static char
LEVEL_MARKET
LIMIT orderstatic char
LEVEL_UNKNOWN
MARKET orderstatic char
SIDE_ASK
Bid (buy) side.static char
SIDE_BID
Unknown action (error).static char
SIDE_UNKNOWN
Ask (sell) side.
-
Constructor Summary
Constructors Constructor Description MamdaOrderBookPriceLevel()
Default constructor.MamdaOrderBookPriceLevel(double price, char side)
MamdaOrderBookPriceLevel(MamdaOrderBookPriceLevel copy)
Construct a price level object which is a shallow copy of the original.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEntriesFromLevel(MamdaOrderBookPriceLevel bookLevel, MamdaOrderBookEntryFilter filter, MamdaOrderBookBasicDeltaList delta)
void
addEntry(MamdaOrderBookEntry entry)
Add a new order book entry to the price level.void
assertEqual(MamdaOrderBookPriceLevel rhs)
Order book price level equality verification.void
checkNotExist(MamdaBookAtomicLevelEntry levelEntry)
If the provided levelEntry entry exists in the price level, as a OrderBookEntry, aMamdaOrderBookException
exception is thrown.void
checkNotExist(MamdaOrderBookEntry entry)
If the provided order book entry exists in the price level aMamdaOrderBookException
exception is thrown.void
clear()
Clear the pricelevelvoid
copy(MamdaBookAtomicLevel copy)
Copy an atomic price level object which is an exact and deep copy of the original.void
copy(MamdaBookAtomicLevelEntry copy)
Copy a price level object which is an exact and deep copy of the original.void
copy(MamdaOrderBookPriceLevel copy)
Copy a price level object which is an exact and deep copy of the original.void
deleteEntriesFromSource(com.wombat.mama.MamaSource source, MamdaOrderBookBasicDeltaList delta)
boolean
empty()
Return whether there are no entries for this level.java.util.Iterator
entryIterator()
Returns ajava.util.Iterator
for all entries within this level.MamdaOrderBookEntry
findEntry(java.lang.String id)
MamdaOrderBookEntry
findOrCreateEntry(java.lang.String id)
char
getAction()
Return the action for this price level.MamdaOrderBookEntry
getEntryAtPosition(long pos)
Return the order book entry at position "pos" in the price level.double
getNumEntries()
Return the actual number of entries for this level.int
getNumEntriesTotal()
char
getOrderType()
com.wombat.mama.MamaPrice
getPrice()
Return the price for this level.char
getSide()
Return the side (bid/ask) of the book for this level.double
getSize()
Return the total size (across all entries) for this level.double
getSizeChange()
Return the size change for this (presumably delta) level.java.lang.String
getSymbol()
com.wombat.mama.MamaDateTime
getTime()
Return the time stamp for when the price level was last updated.void
markAllDeleted()
Mark everything in this price level as deleted, including entries.boolean
reevaluate()
Re-evaluate the price level.void
removeEntry(MamdaBookAtomicLevelEntry levelEntry)
Remove an order book entry from the price level, where the delete details are provied by an atomic levelEntry.void
removeEntry(MamdaOrderBookEntry entry)
Remove an order book entry from the price level.void
removeEntryById(MamdaBookAtomicLevelEntry levelEntry)
void
removeEntryById(MamdaOrderBookEntry entry)
void
setAction(char action)
void
setAsDifference(MamdaOrderBookPriceLevel lhs, MamdaOrderBookPriceLevel rhs)
void
setDetails(MamdaBookAtomicLevel level)
Take the details fromatomic level
and apply them to this level.
void
setDetails(MamdaBookAtomicLevelEntry levelEntry)
Take the details fromatomic levelEntry
and apply them to this levelEntry.
void
setDetails(MamdaOrderBookPriceLevel level)
Take the details fromlevel
and apply them to this level.
void
setNumEntries(double numEntries)
void
setOrderType(char orderType)
void
setPrice(double price)
void
setPrice(com.wombat.mama.MamaPrice price)
void
setSide(char side)
void
setSize(double size)
void
setSizeChange(double size)
static void
setStrictChecking(boolean strict)
Enforce strict checking of order book modifications (at the expense of some performance).void
setTime(com.wombat.mama.MamaDateTime time)
void
updateEntry(MamdaBookAtomicLevelEntry levelEntry)
Update the details of an existing entry in the level, where the update details are provied by an atomic levelEntry.void
updateEntry(MamdaOrderBookEntry entry)
Update the details of an existing entry in the level.
-
-
-
Field Detail
-
ACTION_ADD
public static final char ACTION_ADD
- See Also:
- Constant Field Values
-
ACTION_UPDATE
public static final char ACTION_UPDATE
A new price level.- See Also:
- Constant Field Values
-
ACTION_DELETE
public static final char ACTION_DELETE
Updated price level.- See Also:
- Constant Field Values
-
ACTION_UNKNOWN
public static final char ACTION_UNKNOWN
Deleted price level.- See Also:
- Constant Field Values
-
SIDE_BID
public static final char SIDE_BID
Unknown action (error).- See Also:
- Constant Field Values
-
SIDE_ASK
public static final char SIDE_ASK
Bid (buy) side.- See Also:
- Constant Field Values
-
SIDE_UNKNOWN
public static final char SIDE_UNKNOWN
Ask (sell) side.- See Also:
- Constant Field Values
-
LEVEL_LIMIT
public static final char LEVEL_LIMIT
Unknown side (error).- See Also:
- Constant Field Values
-
LEVEL_MARKET
public static final char LEVEL_MARKET
LIMIT order- See Also:
- Constant Field Values
-
LEVEL_UNKNOWN
public static final char LEVEL_UNKNOWN
MARKET order- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MamdaOrderBookPriceLevel
public MamdaOrderBookPriceLevel()
Default constructor.
-
MamdaOrderBookPriceLevel
public MamdaOrderBookPriceLevel(MamdaOrderBookPriceLevel copy)
Construct a price level object which is a shallow copy of the original.- Parameters:
copy
- The MamdaOrderBookPriceLevel to copy.
-
MamdaOrderBookPriceLevel
public MamdaOrderBookPriceLevel(double price, char side)
-
-
Method Detail
-
clear
public void clear()
Clear the pricelevel
-
copy
public void copy(MamdaOrderBookPriceLevel copy)
Copy a price level object which is an exact and deep copy of the original.- Parameters:
copy
- The MamdaOrderBookPriceLevel to copy.
-
copy
public void copy(MamdaBookAtomicLevel copy)
Copy an atomic price level object which is an exact and deep copy of the original.- Parameters:
copy
- The MamdaOrderBookPriceLevel to copy.
-
copy
public void copy(MamdaBookAtomicLevelEntry copy)
Copy a price level object which is an exact and deep copy of the original.- Parameters:
copy
- The MamdaOrderBookPriceLevel to copy.
-
setPrice
public void setPrice(com.wombat.mama.MamaPrice price)
-
setPrice
public void setPrice(double price)
-
setSize
public void setSize(double size)
-
setSizeChange
public void setSizeChange(double size)
-
setNumEntries
public void setNumEntries(double numEntries)
-
setSide
public void setSide(char side)
-
setAction
public void setAction(char action)
-
setTime
public void setTime(com.wombat.mama.MamaDateTime time)
-
setOrderType
public void setOrderType(char orderType)
-
getOrderType
public char getOrderType()
-
empty
public boolean empty()
Return whether there are no entries for this level.- Returns:
- Whether there are no entries for this level.
-
setDetails
public void setDetails(MamdaOrderBookPriceLevel level)
Take the details fromlevel
and apply them to this level. This does not update entries within the level, only information pertaining to the level itself. It is intended that this method should not be used externally to the API.
- Parameters:
level
- The price level object from which the details are being obtained.
-
setDetails
public void setDetails(MamdaBookAtomicLevel level)
Take the details fromatomic level
and apply them to this level. This does not update entries within the level, only information pertaining to the level itself. It is intended that this method should not be used externally to the API.
- Parameters:
level
- The atomic price level object from which the details are being obtained.
-
setDetails
public void setDetails(MamdaBookAtomicLevelEntry levelEntry)
Take the details fromatomic levelEntry
and apply them to this levelEntry. This update entries within the level. It is intended that this method should not be used externally to the API.
- Parameters:
levelEntry
- The atomic price levelEntry object from which the details are being obtained.
-
addEntry
public void addEntry(MamdaOrderBookEntry entry)
Add a new order book entry to the price level.- Parameters:
entry
- The new entry to be added to the level.- See Also:
MamdaOrderBookEntry
-
updateEntry
public void updateEntry(MamdaOrderBookEntry entry)
Update the details of an existing entry in the level.- Parameters:
entry
- An instance ofMamdaOrderBookEntry
with the new details for the entry in the level.- See Also:
MamdaOrderBookEntry
-
updateEntry
public void updateEntry(MamdaBookAtomicLevelEntry levelEntry)
Update the details of an existing entry in the level, where the update details are provied by an atomic levelEntry.- Parameters:
levelEntry
- An instance ofMamdaBookAtomicLevelEntry
with the new details for the entry in the level.- See Also:
MamdaOrderBookEntry
-
removeEntry
public void removeEntry(MamdaOrderBookEntry entry)
Remove an order book entry from the price level.- Parameters:
entry
- The entry which is to be removed from the price level.- See Also:
MamdaOrderBookEntry
-
removeEntry
public void removeEntry(MamdaBookAtomicLevelEntry levelEntry)
Remove an order book entry from the price level, where the delete details are provied by an atomic levelEntry.- Parameters:
levelEntry
- The entry which is to be removed from the price level.- See Also:
MamdaOrderBookEntry
-
entryIterator
public java.util.Iterator entryIterator()
Returns ajava.util.Iterator
for all entries within this level. Price Level entries are represented by theMamdaOrderBookEntry
class.- Returns:
- Iterator The iterator for the price level entries
-
checkNotExist
public void checkNotExist(MamdaOrderBookEntry entry)
If the provided order book entry exists in the price level aMamdaOrderBookException
exception is thrown. Otherwise the method simply returns.- Parameters:
entry
- The entry whose presence in the level is being determined.- Throws:
MamdaOrderBookException
- If the entry is found in the price level.
-
checkNotExist
public void checkNotExist(MamdaBookAtomicLevelEntry levelEntry)
If the provided levelEntry entry exists in the price level, as a OrderBookEntry, aMamdaOrderBookException
exception is thrown. Otherwise the method simply returns.- Parameters:
entry
- The entry whose presence in the level is being determined.- Throws:
MamdaOrderBookException
- If the entry is found in the price level.
-
markAllDeleted
public void markAllDeleted()
Mark everything in this price level as deleted, including entries.
-
setAsDifference
public void setAsDifference(MamdaOrderBookPriceLevel lhs, MamdaOrderBookPriceLevel rhs)
-
getPrice
public com.wombat.mama.MamaPrice getPrice()
Return the price for this level.- Returns:
- The price for this level.
-
getSize
public double getSize()
Return the total size (across all entries) for this level.- Returns:
- The total size for this level.
-
getSizeChange
public double getSizeChange()
Return the size change for this (presumably delta) level. This attribute is only of interest for delta order books. For full order books, this field will be equal to the size of the price level.- Returns:
- The changed size for this level.
-
getNumEntries
public double getNumEntries()
Return the actual number of entries for this level. The actual number of entries may not equate to the number of entries that can be iterated over if: (a) the feed does not provide the actual entries, or (b) the price level is just a delta.- Returns:
- The actual number of entries for this level.
-
getNumEntriesTotal
public int getNumEntriesTotal()
-
getSide
public char getSide()
Return the side (bid/ask) of the book for this level.- Returns:
- The side of the book for this level.
-
getAction
public char getAction()
Return the action for this price level. All price levels for a full book are marked with ACTION_ADD.- Returns:
- The action for this level.
-
getTime
public com.wombat.mama.MamaDateTime getTime()
Return the time stamp for when the price level was last updated.- Returns:
- The time stamp for when the price level was last updated.
-
assertEqual
public void assertEqual(MamdaOrderBookPriceLevel rhs)
Order book price level equality verification. A MamdaOrderBookException is thrown if the price levels are not equal, along with the reason for the inequality.- Throws:
MamdaOrderBookException
-
setStrictChecking
public static void setStrictChecking(boolean strict)
Enforce strict checking of order book modifications (at the expense of some performance). This setting is automatically updated by MamdaOrderBook::setStrictChecking().
-
getSymbol
public java.lang.String getSymbol()
-
removeEntryById
public void removeEntryById(MamdaOrderBookEntry entry)
-
removeEntryById
public void removeEntryById(MamdaBookAtomicLevelEntry levelEntry)
-
addEntriesFromLevel
public void addEntriesFromLevel(MamdaOrderBookPriceLevel bookLevel, MamdaOrderBookEntryFilter filter, MamdaOrderBookBasicDeltaList delta)
-
deleteEntriesFromSource
public void deleteEntriesFromSource(com.wombat.mama.MamaSource source, MamdaOrderBookBasicDeltaList delta)
-
reevaluate
public boolean reevaluate()
Re-evaluate the price level. This would be performed after the status of sources and/or subsources of an "aggregated order book" (i.e., a book built from multiple sources) have changed.- Returns:
- Whether the book info changed based on the re-evaluation.
-
getEntryAtPosition
public MamdaOrderBookEntry getEntryAtPosition(long pos)
Return the order book entry at position "pos" in the price level.- Parameters:
pos
- The position of the order book entry.- Returns:
- The order book entry or NULL if not found.
-
findOrCreateEntry
public MamdaOrderBookEntry findOrCreateEntry(java.lang.String id)
-
findEntry
public MamdaOrderBookEntry findEntry(java.lang.String id)
-
-