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 charACTION_ADDstatic charACTION_DELETEUpdated price level.static charACTION_UNKNOWNDeleted price level.static charACTION_UPDATEA new price level.static charLEVEL_LIMITUnknown side (error).static charLEVEL_MARKETLIMIT orderstatic charLEVEL_UNKNOWNMARKET orderstatic charSIDE_ASKBid (buy) side.static charSIDE_BIDUnknown action (error).static charSIDE_UNKNOWNAsk (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 voidaddEntriesFromLevel(MamdaOrderBookPriceLevel bookLevel, MamdaOrderBookEntryFilter filter, MamdaOrderBookBasicDeltaList delta)voidaddEntry(MamdaOrderBookEntry entry)Add a new order book entry to the price level.voidassertEqual(MamdaOrderBookPriceLevel rhs)Order book price level equality verification.voidcheckNotExist(MamdaBookAtomicLevelEntry levelEntry)If the provided levelEntry entry exists in the price level, as a OrderBookEntry, aMamdaOrderBookExceptionexception is thrown.voidcheckNotExist(MamdaOrderBookEntry entry)If the provided order book entry exists in the price level aMamdaOrderBookExceptionexception is thrown.voidclear()Clear the pricelevelvoidcopy(MamdaBookAtomicLevel copy)Copy an atomic price level object which is an exact and deep copy of the original.voidcopy(MamdaBookAtomicLevelEntry copy)Copy a price level object which is an exact and deep copy of the original.voidcopy(MamdaOrderBookPriceLevel copy)Copy a price level object which is an exact and deep copy of the original.voiddeleteEntriesFromSource(com.wombat.mama.MamaSource source, MamdaOrderBookBasicDeltaList delta)booleanempty()Return whether there are no entries for this level.java.util.IteratorentryIterator()Returns ajava.util.Iteratorfor all entries within this level.MamdaOrderBookEntryfindEntry(java.lang.String id)MamdaOrderBookEntryfindOrCreateEntry(java.lang.String id)chargetAction()Return the action for this price level.MamdaOrderBookEntrygetEntryAtPosition(long pos)Return the order book entry at position "pos" in the price level.doublegetNumEntries()Return the actual number of entries for this level.intgetNumEntriesTotal()chargetOrderType()com.wombat.mama.MamaPricegetPrice()Return the price for this level.chargetSide()Return the side (bid/ask) of the book for this level.doublegetSize()Return the total size (across all entries) for this level.doublegetSizeChange()Return the size change for this (presumably delta) level.java.lang.StringgetSymbol()com.wombat.mama.MamaDateTimegetTime()Return the time stamp for when the price level was last updated.voidmarkAllDeleted()Mark everything in this price level as deleted, including entries.booleanreevaluate()Re-evaluate the price level.voidremoveEntry(MamdaBookAtomicLevelEntry levelEntry)Remove an order book entry from the price level, where the delete details are provied by an atomic levelEntry.voidremoveEntry(MamdaOrderBookEntry entry)Remove an order book entry from the price level.voidremoveEntryById(MamdaBookAtomicLevelEntry levelEntry)voidremoveEntryById(MamdaOrderBookEntry entry)voidsetAction(char action)voidsetAsDifference(MamdaOrderBookPriceLevel lhs, MamdaOrderBookPriceLevel rhs)voidsetDetails(MamdaBookAtomicLevel level)Take the details fromatomic leveland apply them to this level.voidsetDetails(MamdaBookAtomicLevelEntry levelEntry)Take the details fromatomic levelEntryand apply them to this levelEntry.voidsetDetails(MamdaOrderBookPriceLevel level)Take the details fromleveland apply them to this level.voidsetNumEntries(double numEntries)voidsetOrderType(char orderType)voidsetPrice(double price)voidsetPrice(com.wombat.mama.MamaPrice price)voidsetSide(char side)voidsetSize(double size)voidsetSizeChange(double size)static voidsetStrictChecking(boolean strict)Enforce strict checking of order book modifications (at the expense of some performance).voidsetTime(com.wombat.mama.MamaDateTime time)voidupdateEntry(MamdaBookAtomicLevelEntry levelEntry)Update the details of an existing entry in the level, where the update details are provied by an atomic levelEntry.voidupdateEntry(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 fromleveland 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 leveland 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 levelEntryand 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 ofMamdaOrderBookEntrywith 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 ofMamdaBookAtomicLevelEntrywith 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.Iteratorfor all entries within this level. Price Level entries are represented by theMamdaOrderBookEntryclass.- 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 aMamdaOrderBookExceptionexception 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, aMamdaOrderBookExceptionexception 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)
-
-