net.sourceforge.jasa.market.auctioneer
Class AbstractAuctioneer

java.lang.Object
  extended by net.sourceforge.jasa.market.auctioneer.AbstractAuctioneer
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, MarketEventListener, Auctioneer, QuoteProvider
Direct Known Subclasses:
SealedBidAuctioneer, TransparentAuctioneer

public abstract class AbstractAuctioneer
extends java.lang.Object
implements java.io.Serializable, Auctioneer, java.lang.Cloneable

An abstract class representing an auctioneer managing shouts in an market. Different market rules should be encapsulated in different Auctioneer classes.

See Also:
Serialized Form
 

Field Summary
protected  ClearingPolicy clearingPolicy
           
protected  MarketQuote clearingQuote
           
protected  MarketQuote currentQuote
           
protected  Market market
           
protected  OrderBook orderBook
           
protected  PricingPolicy pricingPolicy
           
 
Constructor Summary
AbstractAuctioneer()
           
AbstractAuctioneer(Market auction)
           
 
Method Summary
 java.util.Iterator<Order> askIterator()
           
 double askQuote()
           
 java.util.Iterator<Order> bidIterator()
           
 double bidQuote()
           
protected  void checkShoutValidity(Order shout)
           
 void clear()
          Perform the clearing operation for the market; match buyers with sellers and inform the market of any deals.
 void clear(Order ask, Order bid, double price)
           
 void clear(Order ask, Order bid, double buyerCharge, double sellerPayment, int quantity)
           
 double determineClearingPrice(Order bid, Order ask)
           
 void eventOccurred(SimEvent event)
           
abstract  void generateQuote()
           
 ClearingPolicy getClearingPolicy()
           
 MarketQuote getClearingQuote()
           
 Market getMarket()
          Find out which market we are the auctioneer for.
 OrderBook getOrderBook()
           
 PricingPolicy getPricingPolicy()
           
 MarketQuote getQuote()
           
 java.util.List<Order> getUnmatchedAsks()
           
 java.util.List<Order> getUnmatchedBids()
           
protected  void initialise()
           
 void newOrder(Order shout)
          Code for handling a new shout in the market.
protected  void newShoutInternal(Order shout)
           
 void onEndOfDay()
           
abstract  void onRoundClosed()
           
 void printState()
          Log the current state of the market.
 java.lang.Object protoClone()
           
 void recordMatch(Order ask, Order bid)
           
 void removeOrder(Order shout)
          Handle a request to retract a shout.
 void reset()
           
 void setClearingPolicy(ClearingPolicy clearingPolicy)
           
 void setClearingQuote(MarketQuote clearingQuote)
           
 void setMarket(Market auction)
          Specify which market we are the auctioneer for.
 void setOrderBook(OrderBook orderBook)
           
 void setPricingPolicy(PricingPolicy pricingPolicy)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface net.sourceforge.jasa.market.auctioneer.Auctioneer
getAccount, getLastAsk, getLastBid, getLastShout, orderFilled, shoutsVisible, transactionsOccurred
 

Field Detail

market

protected Market market

orderBook

protected OrderBook orderBook

currentQuote

protected MarketQuote currentQuote

clearingQuote

protected MarketQuote clearingQuote

pricingPolicy

protected PricingPolicy pricingPolicy

clearingPolicy

protected ClearingPolicy clearingPolicy
Constructor Detail

AbstractAuctioneer

public AbstractAuctioneer(Market auction)

AbstractAuctioneer

public AbstractAuctioneer()
Method Detail

protoClone

public java.lang.Object protoClone()

getPricingPolicy

public PricingPolicy getPricingPolicy()

setPricingPolicy

public void setPricingPolicy(PricingPolicy pricingPolicy)

newOrder

public void newOrder(Order shout)
              throws IllegalOrderException,
                     DuplicateShoutException
Code for handling a new shout in the market. Subclasses should override this method if they wish to provide different handling for different market rules.

Specified by:
newOrder in interface Auctioneer
Parameters:
shout - The new shout to be processed
Throws:
IllegalOrderException - Thrown if the shout is invalid in some way.
DuplicateShoutException

newShoutInternal

protected void newShoutInternal(Order shout)
                         throws DuplicateShoutException
Throws:
DuplicateShoutException

checkShoutValidity

protected void checkShoutValidity(Order shout)
                           throws IllegalOrderException
Parameters:
shout - The new shout to be processed
Throws:
IllegalOrderException - Thrown if the shout is invalid in some way.

removeOrder

public void removeOrder(Order shout)
Handle a request to retract a shout.

Specified by:
removeOrder in interface Auctioneer

printState

public void printState()
Log the current state of the market.

Specified by:
printState in interface Auctioneer

reset

public void reset()

initialise

protected void initialise()

getQuote

public MarketQuote getQuote()
Specified by:
getQuote in interface QuoteProvider

askIterator

public java.util.Iterator<Order> askIterator()
Specified by:
askIterator in interface Auctioneer

bidIterator

public java.util.Iterator<Order> bidIterator()
Specified by:
bidIterator in interface Auctioneer

generateQuote

public abstract void generateQuote()

setMarket

public void setMarket(Market auction)
Description copied from interface: Auctioneer
Specify which market we are the auctioneer for.

Specified by:
setMarket in interface Auctioneer

getMarket

public Market getMarket()
Find out which market we are the auctioneer for.

Specified by:
getMarket in interface Auctioneer

onEndOfDay

public void onEndOfDay()

clear

public void clear()
Description copied from interface: Auctioneer
Perform the clearing operation for the market; match buyers with sellers and inform the market of any deals.

Specified by:
clear in interface Auctioneer

clear

public void clear(Order ask,
                  Order bid,
                  double price)

clear

public void clear(Order ask,
                  Order bid,
                  double buyerCharge,
                  double sellerPayment,
                  int quantity)

determineClearingPrice

public double determineClearingPrice(Order bid,
                                     Order ask)

bidQuote

public double bidQuote()

askQuote

public double askQuote()

eventOccurred

public void eventOccurred(SimEvent event)

onRoundClosed

public abstract void onRoundClosed()

recordMatch

public void recordMatch(Order ask,
                        Order bid)

getOrderBook

public OrderBook getOrderBook()

setOrderBook

public void setOrderBook(OrderBook orderBook)

getUnmatchedAsks

public java.util.List<Order> getUnmatchedAsks()
Specified by:
getUnmatchedAsks in interface Auctioneer

getUnmatchedBids

public java.util.List<Order> getUnmatchedBids()
Specified by:
getUnmatchedBids in interface Auctioneer

getClearingQuote

public MarketQuote getClearingQuote()

setClearingQuote

public void setClearingQuote(MarketQuote clearingQuote)

getClearingPolicy

public ClearingPolicy getClearingPolicy()

setClearingPolicy

public void setClearingPolicy(ClearingPolicy clearingPolicy)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object