net.commerce.zocalo.market
Class Market

java.lang.Object
  extended by net.commerce.zocalo.market.Market
Direct Known Subclasses:
BinaryMarket, MultiMarket

public abstract class Market
extends java.lang.Object

a Market in a claim; always supports book orders, sometimes supports a marketMaker. Responsibilities include reporting on price levels and book contents as well as buying claims.


Field Summary
protected  Price maxPrice
           
 
Method Summary
 Price asPrice(java.math.BigDecimal decimal)
           
 Price asPrice(Quantity q)
           
protected abstract  void buyAtMarketPrice(Position pos, Price price, Quantity quantity, User user)
           
protected abstract  void buyOrAddBookOrder(Position pos, Price price, Quantity quantity, User user)
           
abstract  Quantity buyWithCostLimit(Position position, Price price, Quantity costLimit, User user, boolean isBuy)
           
 void close()
           
 Price currentPrice(Position position)
           
 Probability currentProbability(Position position)
           
 Quantity decideClaimAndRecord(Position pos)
           
 java.lang.String describeOutcome()
           
protected  boolean gateKeeper(Position pos, Price price, Quantity quantity, User user, boolean marketOrder)
           
 Book getBook()
           
abstract  Claim getClaim()
           
 java.util.Date getLastTrade()
           
 Price getMaxPrice()
          Deprecated.  
 java.lang.String getName()
           
 Outcome getOutcome()
          Deprecated.  
 User getOwner()
           
 boolean hasMaker()
           
 boolean identifyCouponBank(CouponBank bank)
           
 boolean isOpen()
           
 void limitOrder(Position pos, Price price, Quantity quantity, User user)
          buy TOTALQUANTITY of coupons, while not raising the price above PRICE.
abstract  void marketCallBack(MarketCallback callback)
           
 void marketOrder(Position pos, Price price, Quantity quantity, User user)
          buy TOTALQUANTITY of coupons, while not raising the price above PRICE.
abstract  Price maxPrice()
           
 Quantity mintBalance()
           
 void open()
           
 Probability outcome(Position pos)
           
 boolean outcomeIsContinuous()
           
 Coupons[] printNewCouponSets(Quantity quantity, Funds bothFunds)
           
abstract  void recordBookTrade(User acceptor, Price price, Quantity quantity, Position position)
           
abstract  void recordLimitTrade(Order order, Quantity quantityTraded, Position position)
           
 Quantity requiredReserves(User user)
           
 boolean requireReserves()
           
 void resetBook()
           
 Price scaleToPrice(Quantity price)
           
 void sellHoldings(User user, Position position)
           
abstract  void setClaim(Claim claim)
           
abstract  void setMaker(MarketMaker mm)
           
 void setMaxPrice(Price maxP)
          Deprecated.  
 void setOutcome(Outcome outcome)
          Deprecated.  
 void setOwner(SecureUser owner)
          Deprecated.  
 void setRequireReserves(boolean requireReserves)
          Deprecated.  
protected  void setReserveVerifier(ReserveVerifier reserveVerifier)
           
 Accounts settle(Quantity quantity, java.util.Map couponsMap)
           
 void setWholeShareTradingOnly()
           
 boolean verifyPriceRange(Quantity price)
           
protected  boolean verifyReserves(User user, Position pos, Price price, Quantity quantity)
           
 boolean wholeShareTradingOnly()
           
 void withholdReserves(Order order, Quantity quantity, Position position)
           
protected  void withholdReserves(User user, Quantity quantityPurchased, Position pos)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxPrice

protected Price maxPrice
Method Detail

getBook

public Book getBook()

currentProbability

public Probability currentProbability(Position position)

currentPrice

public Price currentPrice(Position position)

getName

public java.lang.String getName()

setClaim

public abstract void setClaim(Claim claim)

getClaim

public abstract Claim getClaim()

setMaker

public abstract void setMaker(MarketMaker mm)

recordLimitTrade

public abstract void recordLimitTrade(Order order,
                                      Quantity quantityTraded,
                                      Position position)

recordBookTrade

public abstract void recordBookTrade(User acceptor,
                                     Price price,
                                     Quantity quantity,
                                     Position position)

maxPrice

public abstract Price maxPrice()

verifyPriceRange

public boolean verifyPriceRange(Quantity price)

asPrice

public Price asPrice(Quantity q)

asPrice

public Price asPrice(java.math.BigDecimal decimal)

scaleToPrice

public Price scaleToPrice(Quantity price)

hasMaker

public boolean hasMaker()

limitOrder

public void limitOrder(Position pos,
                       Price price,
                       Quantity quantity,
                       User user)
                throws DuplicateOrderException
buy TOTALQUANTITY of coupons, while not raising the price above PRICE. If price is above the market level, immediately buy coupons up to the market price, totalQuantity or user's spending limit. If price is lower, enter a book only order. Enter a book order for coupons not purchased immediately.

Throws:
DuplicateOrderException

marketOrder

public void marketOrder(Position pos,
                        Price price,
                        Quantity quantity,
                        User user)
buy TOTALQUANTITY of coupons, while not raising the price above PRICE. If price is above the market level, immediately buy coupons up to the market price, totalQuantity or user's spending limit. If price is lower, do nothing.


buyAtMarketPrice

protected abstract void buyAtMarketPrice(Position pos,
                                         Price price,
                                         Quantity quantity,
                                         User user)

buyOrAddBookOrder

protected abstract void buyOrAddBookOrder(Position pos,
                                          Price price,
                                          Quantity quantity,
                                          User user)
                                   throws DuplicateOrderException
Throws:
DuplicateOrderException

gateKeeper

protected boolean gateKeeper(Position pos,
                             Price price,
                             Quantity quantity,
                             User user,
                             boolean marketOrder)

buyWithCostLimit

public abstract Quantity buyWithCostLimit(Position position,
                                          Price price,
                                          Quantity costLimit,
                                          User user,
                                          boolean isBuy)

sellHoldings

public void sellHoldings(User user,
                         Position position)

close

public void close()

open

public void open()

isOpen

public boolean isOpen()

resetBook

public void resetBook()

getLastTrade

public java.util.Date getLastTrade()

settle

public Accounts settle(Quantity quantity,
                       java.util.Map couponsMap)

printNewCouponSets

public Coupons[] printNewCouponSets(Quantity quantity,
                                    Funds bothFunds)

decideClaimAndRecord

public Quantity decideClaimAndRecord(Position pos)

setWholeShareTradingOnly

public void setWholeShareTradingOnly()

wholeShareTradingOnly

public boolean wholeShareTradingOnly()

requireReserves

public boolean requireReserves()

withholdReserves

protected void withholdReserves(User user,
                                Quantity quantityPurchased,
                                Position pos)

withholdReserves

public void withholdReserves(Order order,
                             Quantity quantity,
                             Position position)

verifyReserves

protected boolean verifyReserves(User user,
                                 Position pos,
                                 Price price,
                                 Quantity quantity)

requiredReserves

public Quantity requiredReserves(User user)
                          throws ScoreException
Throws:
ScoreException

setReserveVerifier

protected void setReserveVerifier(ReserveVerifier reserveVerifier)

setRequireReserves

public void setRequireReserves(boolean requireReserves)
Deprecated. 


getOwner

public User getOwner()

setOwner

public void setOwner(SecureUser owner)
Deprecated. 


getOutcome

public Outcome getOutcome()
Deprecated. 


setOutcome

public void setOutcome(Outcome outcome)
Deprecated. 


identifyCouponBank

public boolean identifyCouponBank(CouponBank bank)

mintBalance

public Quantity mintBalance()

outcome

public Probability outcome(Position pos)

outcomeIsContinuous

public boolean outcomeIsContinuous()

describeOutcome

public java.lang.String describeOutcome()

marketCallBack

public abstract void marketCallBack(MarketCallback callback)

setMaxPrice

public void setMaxPrice(Price maxP)
Deprecated. 


getMaxPrice

public Price getMaxPrice()
Deprecated.