net.commerce.zocalo.market
Class Book
java.lang.Object
net.commerce.zocalo.market.Book
- Direct Known Subclasses:
- BinaryBook, UnaryBook
public abstract class Book
- extends java.lang.Object
A Book holds orders entered by Users to buy and sell positions on a particular Claim.
Method Summary |
Order |
addOrder(Position position,
Price price,
Quantity quantity,
User user)
|
Price |
bestBuyOfferFor(Position position)
|
Quantity |
bestQuantity(Position position)
|
Price |
bestSellOfferFor(Position position)
|
java.lang.String |
buildPriceList(Position pos)
|
Quantity |
buyFromBestBookOrders(Position position,
Price price,
Quantity quantity,
User user)
buy up to price worth or quantity coupons from the orders at the book's best price. |
Quantity |
buyFromBookOrders(Position position,
Price price,
Quantity quantity,
User buyer)
buy up to price worth or quantity coupons from the orders in the book. |
protected void |
cancelOrder(User buyer,
Order order)
|
Claim |
getClaim()
|
protected Market |
getMarket()
|
SortedOrders |
getOffers(Position position)
|
boolean |
hasOrdersToSell()
|
boolean |
hasOrdersToSell(Position position)
|
java.util.Iterator |
iterateOffers(Position pos)
|
protected void |
recordBookTrade(User acceptor,
Price price,
Quantity quantity,
Position position)
|
boolean |
removeOrder(Order order)
|
boolean |
removeOrder(java.lang.String userName,
Price price,
Position pos)
|
void |
resetOrders()
|
void |
setClaim(Claim claim)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Book
public Book(Claim claim,
Market market)
buyFromBookOrders
public Quantity buyFromBookOrders(Position position,
Price price,
Quantity quantity,
User buyer)
- buy up to price worth or quantity coupons from the orders in the book. This method
is called when there is no marketMaker. This method will only fill the portion of the order
that can be satisfied immediately.
buyFromBestBookOrders
public Quantity buyFromBestBookOrders(Position position,
Price price,
Quantity quantity,
User user)
- buy up to price worth or quantity coupons from the orders at the book's best price.
This is used when coupons are purchased from the book and the marketMaker. In order
to ensure that the best price is always used, the market has to buy book orders until
the price changes, then buy from the maker until the next price frontier is reached.
addOrder
public Order addOrder(Position position,
Price price,
Quantity quantity,
User user)
throws DuplicateOrderException,
IncompatibleOrderException
- Throws:
DuplicateOrderException
IncompatibleOrderException
removeOrder
public boolean removeOrder(Order order)
removeOrder
public boolean removeOrder(java.lang.String userName,
Price price,
Position pos)
recordBookTrade
protected void recordBookTrade(User acceptor,
Price price,
Quantity quantity,
Position position)
cancelOrder
protected void cancelOrder(User buyer,
Order order)
resetOrders
public void resetOrders()
getClaim
public Claim getClaim()
setClaim
public void setClaim(Claim claim)
getOffers
public SortedOrders getOffers(Position position)
bestSellOfferFor
public Price bestSellOfferFor(Position position)
bestBuyOfferFor
public Price bestBuyOfferFor(Position position)
bestQuantity
public Quantity bestQuantity(Position position)
hasOrdersToSell
public boolean hasOrdersToSell(Position position)
hasOrdersToSell
public boolean hasOrdersToSell()
iterateOffers
public java.util.Iterator iterateOffers(Position pos)
getMarket
protected Market getMarket()
buildPriceList
public java.lang.String buildPriceList(Position pos)