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,
double price,
double quantity,
User user)
|
double |
bestBuyOfferFor(Position position)
|
double |
bestQuantity(Position position)
|
double |
bestSellOfferFor(Position position)
|
java.lang.String |
buildPriceList(Position pos)
|
double |
buyFromBestBookOrders(Position position,
double price,
double quantity,
User user)
buy up to price worth or quantity coupons from the orders at the book's best price. |
double |
buyFromBookOrders(Position position,
double price,
double 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 static boolean |
lessOrEqualToPrintingPrecision(double orderPrice,
double price)
|
protected void |
recordTransaction(User acceptor,
double price,
double quantity,
Position position)
|
boolean |
removeOrder(Order order)
|
boolean |
removeOrder(java.lang.String userName,
double price,
Position pos)
|
void |
resetOrders()
|
double |
scalePrice(double price)
|
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 double buyFromBookOrders(Position position,
double price,
double 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 double buyFromBestBookOrders(Position position,
double price,
double 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,
double price,
double quantity,
User user)
throws DuplicateOrderException
- Throws:
DuplicateOrderException
removeOrder
public boolean removeOrder(Order order)
removeOrder
public boolean removeOrder(java.lang.String userName,
double price,
Position pos)
lessOrEqualToPrintingPrecision
protected static boolean lessOrEqualToPrintingPrecision(double orderPrice,
double price)
recordTransaction
protected void recordTransaction(User acceptor,
double price,
double 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 double bestSellOfferFor(Position position)
bestBuyOfferFor
public double bestBuyOfferFor(Position position)
bestQuantity
public double bestQuantity(Position position)
hasOrdersToSell
public boolean hasOrdersToSell(Position position)
hasOrdersToSell
public boolean hasOrdersToSell()
iterateOffers
public java.util.Iterator iterateOffers(Position pos)
scalePrice
public double scalePrice(double price)
getMarket
protected Market getMarket()
buildPriceList
public java.lang.String buildPriceList(Position pos)