edu.cuny.cat.market
Class GenericDoubleAuctioneer

java.lang.Object
  extended by edu.cuny.cat.market.GenericDoubleAuctioneer
All Implemented Interfaces:
AuctionEventListener, Auctioneer, QuoteProvider, edu.cuny.config.param.Parameterizable, edu.cuny.obj.Prototypeable, edu.cuny.obj.Resetable, java.io.Serializable, java.lang.Cloneable

public class GenericDoubleAuctioneer
extends java.lang.Object
implements java.io.Serializable, Auctioneer, edu.cuny.obj.Resetable, edu.cuny.obj.Prototypeable, java.lang.Cloneable, edu.cuny.config.param.Parameterizable

A generic implementation of Auctioneer framework.

Parameters

base.shoutengine
class, inheriting ShoutEngine
(the engine matching shouts)
base.quoting
class, implementing QuotingPolicy
(the quoting policy)
base.charging
class, inheriting ChargingPolicy
(the charging policy)
base.clearing
class, inheriting MarketClearingCondition
(the clearing condition)
base.accepting
class, inheriting ShoutAcceptingPolicy
(the shout accepting policy)
base.pricing
class, inheriting PricingPolicy
(the pricing policy)

Default Base

generic_double_auctioneer

Version:
$Revision: 1.40 $
Author:
Jinzhong Niu
See Also:
Serialized Form

Field Summary
protected  ShoutAcceptingPolicy acceptingPolicy
           
protected  ChargingPolicy chargingPolicy
           
protected  MarketClearingCondition clearingCondition
           
protected  MarketQuote currentQuote
          The current quote
protected  java.util.Map<java.lang.String,Transaction> executedTransactions
          The set of transactions that have been made in the current round.
protected  java.util.Map<java.lang.Class<? extends Helper>,Helper> helpers
          helper components that are required and shared by policies to provide additional capabilities.
protected  java.lang.String name
           
static java.lang.String P_ACCEPTING
           
static java.lang.String P_CHARGING
           
static java.lang.String P_CLEARING
           
static java.lang.String P_DEF_BASE
           
static java.lang.String P_MATCHING
           
static java.lang.String P_PRICING
           
static java.lang.String P_QUOTING
           
static java.lang.String P_SUBSCRIBING
           
protected  org.apache.commons.collections15.Buffer<Transaction> pendingTransactions
           
protected  PricingPolicy pricingPolicy
           
protected  QuotingPolicy quotingPolicy
           
protected  MarketRegistry registry
           
protected  ShoutEngine shoutEngine
          The shout engine for this auction.
protected  java.util.Map<java.lang.String,Shout> shouts
          records all the shouts still standing at this auction, which may be in shoutEngine or involved in pendingTransactions.
protected  SubscribingPolicy subscribingPolicy
           
 
Constructor Summary
GenericDoubleAuctioneer()
           
 
Method Summary
 java.util.Iterator<Shout> askIterator()
           
 double askQuote()
           
 java.util.Iterator<Shout> bidIterator()
           
 double bidQuote()
           
 void clear()
          Perform the clearing operation for the auction; match buyers with sellers and inform the auction of any deals.
protected  void clear(Shout ask, Shout bid, double price)
           
 double determineClearingPrice(Shout bid, Shout ask, MarketQuote clearingQuote)
           
 void eventOccurred(AuctionEvent event)
           
 ShoutAcceptingPolicy getAcceptingPolicy()
           
 ChargingPolicy getChargingPolicy()
           
 MarketClearingCondition getClearingCondition()
           
<H extends Helper>
H
getHelper(java.lang.Class<H> type)
           
 java.lang.String getName()
           
 PricingPolicy getPricingPolicy()
           
 MarketQuote getQuote()
          TODO: the quote returned may not be the latest quote for the market.
 QuotingPolicy getQuotingPolicy()
           
 MarketRegistry getRegistry()
           
 Shout getShout(java.lang.String shoutId)
          retrieves the shout with the specified id, which may be still in shoutEngine, or in a pending transaction.
 ShoutEngine getShoutEngine()
           
 SubscribingPolicy getSubscribingPolicy()
           
 void newShout(Shout shout)
          Code for handling a new shout in the auction.
 void printState()
          Log the current status of the auction.
protected  void processDayClosed(DayClosedEvent event)
           
protected  void processGameOver(GameOverEvent event)
           
protected  void processShoutPlaced(ShoutPlacedEvent event)
          caches all the successfully placed shout in shouts.
protected  void processTransactionExecuted(TransactionExecutedEvent event)
           
protected  void processTransactionRejected(TransactionRejectedEvent event)
           
 java.lang.Object protoClone()
           
 void removeShout(Shout shout)
          Handle a request to retract a shout.
 void reset()
           
 void setAcceptingPolicy(ShoutAcceptingPolicy acceptingPolicy)
           
 void setChargingPolicy(ChargingPolicy chargingPolicy)
           
 void setClearingCondition(MarketClearingCondition clearingCondition)
           
<H extends Helper>
void
setHelper(java.lang.Class<H> type, H helper)
          register a Helper, which can be retrieved and used by AuctioneerPolicy to have additional capabilities that are shared with other policies.
 void setName(java.lang.String name)
           
 void setPricingPolicy(PricingPolicy pricingPolicy)
           
 void setQuotingPolicy(QuotingPolicy quotingPolicy)
           
 void setRegistry(MarketRegistry registry)
           
 void setShoutEngine(ShoutEngine shoutEngine)
           
 void setSubscribingPolicy(SubscribingPolicy subscribingPolicy)
           
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 java.lang.String toString()
           
protected  void updateQuote()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

P_MATCHING

public static final java.lang.String P_MATCHING
See Also:
Constant Field Values

P_QUOTING

public static final java.lang.String P_QUOTING
See Also:
Constant Field Values

P_PRICING

public static final java.lang.String P_PRICING
See Also:
Constant Field Values

P_CLEARING

public static final java.lang.String P_CLEARING
See Also:
Constant Field Values

P_ACCEPTING

public static final java.lang.String P_ACCEPTING
See Also:
Constant Field Values

P_CHARGING

public static final java.lang.String P_CHARGING
See Also:
Constant Field Values

P_SUBSCRIBING

public static final java.lang.String P_SUBSCRIBING
See Also:
Constant Field Values

P_DEF_BASE

public static final java.lang.String P_DEF_BASE
See Also:
Constant Field Values

shoutEngine

protected ShoutEngine shoutEngine
The shout engine for this auction.


executedTransactions

protected java.util.Map<java.lang.String,Transaction> executedTransactions
The set of transactions that have been made in the current round.


pendingTransactions

protected org.apache.commons.collections15.Buffer<Transaction> pendingTransactions

shouts

protected java.util.Map<java.lang.String,Shout> shouts
records all the shouts still standing at this auction, which may be in shoutEngine or involved in pendingTransactions.


currentQuote

protected MarketQuote currentQuote
The current quote


name

protected java.lang.String name

quotingPolicy

protected QuotingPolicy quotingPolicy

pricingPolicy

protected PricingPolicy pricingPolicy

chargingPolicy

protected ChargingPolicy chargingPolicy

clearingCondition

protected MarketClearingCondition clearingCondition

acceptingPolicy

protected ShoutAcceptingPolicy acceptingPolicy

subscribingPolicy

protected SubscribingPolicy subscribingPolicy

registry

protected MarketRegistry registry

helpers

protected java.util.Map<java.lang.Class<? extends Helper>,Helper> helpers
helper components that are required and shared by policies to provide additional capabilities.

Constructor Detail

GenericDoubleAuctioneer

public GenericDoubleAuctioneer()
Method Detail

setup

public void setup(edu.cuny.config.param.ParameterDatabase parameters,
                  edu.cuny.config.param.Parameter base)
Specified by:
setup in interface edu.cuny.config.param.Parameterizable

reset

public void reset()
Specified by:
reset in interface edu.cuny.obj.Resetable

protoClone

public java.lang.Object protoClone()
Specified by:
protoClone in interface edu.cuny.obj.Prototypeable

getName

public java.lang.String getName()
Specified by:
getName in interface Auctioneer
Returns:
the name of the auction.

setName

public void setName(java.lang.String name)
Specified by:
setName in interface Auctioneer
Parameters:
name - the name for the auction.

getQuotingPolicy

public QuotingPolicy getQuotingPolicy()
Specified by:
getQuotingPolicy in interface Auctioneer
Returns:
the quoting policy used in the auction.

setQuotingPolicy

public void setQuotingPolicy(QuotingPolicy quotingPolicy)

getPricingPolicy

public PricingPolicy getPricingPolicy()
Specified by:
getPricingPolicy in interface Auctioneer
Returns:
the pricing policy used in the auction.

setPricingPolicy

public void setPricingPolicy(PricingPolicy pricingPolicy)

setClearingCondition

public void setClearingCondition(MarketClearingCondition clearingCondition)

getClearingCondition

public MarketClearingCondition getClearingCondition()
Specified by:
getClearingCondition in interface Auctioneer
Returns:
the clearning condition used in the auction.

setChargingPolicy

public void setChargingPolicy(ChargingPolicy chargingPolicy)

getChargingPolicy

public ChargingPolicy getChargingPolicy()
Specified by:
getChargingPolicy in interface Auctioneer
Returns:
the charging policy used in the auction.

setAcceptingPolicy

public void setAcceptingPolicy(ShoutAcceptingPolicy acceptingPolicy)

getAcceptingPolicy

public ShoutAcceptingPolicy getAcceptingPolicy()
Specified by:
getAcceptingPolicy in interface Auctioneer
Returns:
the shout accepting policy in the auction.

getSubscribingPolicy

public SubscribingPolicy getSubscribingPolicy()
Specified by:
getSubscribingPolicy in interface Auctioneer
Returns:
the subscribing policy in the auction.

setSubscribingPolicy

public void setSubscribingPolicy(SubscribingPolicy subscribingPolicy)

setShoutEngine

public void setShoutEngine(ShoutEngine shoutEngine)

getShoutEngine

public ShoutEngine getShoutEngine()
Specified by:
getShoutEngine in interface Auctioneer
Returns:
the shout engine used by the auctioneer.

getRegistry

public MarketRegistry getRegistry()
Specified by:
getRegistry in interface Auctioneer
Returns:
the registry used by the specialist.

setRegistry

public void setRegistry(MarketRegistry registry)

getHelper

public <H extends Helper> H getHelper(java.lang.Class<H> type)
Specified by:
getHelper in interface Auctioneer
Parameters:
type - the class of the requested Helper
Returns:
helper component of the given type

setHelper

public <H extends Helper> void setHelper(java.lang.Class<H> type,
                                         H helper)
Description copied from interface: Auctioneer
register a Helper, which can be retrieved and used by AuctioneerPolicy to have additional capabilities that are shared with other policies.

Specified by:
setHelper in interface Auctioneer
Parameters:
type - the class of the Helper
helper -

newShout

public void newShout(Shout shout)
              throws IllegalShoutException,
                     DuplicateShoutException
Code for handling a new shout in the auction. Subclasses should override this method if they wish to provide different handling for different auction rules.

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

removeShout

public void removeShout(Shout shout)
Handle a request to retract a shout.

Specified by:
removeShout in interface Auctioneer

getShout

public Shout getShout(java.lang.String shoutId)
retrieves the shout with the specified id, which may be still in shoutEngine, or in a pending transaction.

Specified by:
getShout in interface Auctioneer
Parameters:
shoutId - the id of desired shout.
Returns:
the shout with the id

printState

public void printState()
Log the current status of the auction.

Specified by:
printState in interface Auctioneer

askIterator

public java.util.Iterator<Shout> askIterator()
Specified by:
askIterator in interface Auctioneer
Returns:
an iteration of asks in the auction.

bidIterator

public java.util.Iterator<Shout> bidIterator()
Specified by:
bidIterator in interface Auctioneer
Returns:
an iteration of bids in the auction.

getQuote

public MarketQuote getQuote()
TODO: the quote returned may not be the latest quote for the market. Modify it !

Specified by:
getQuote in interface QuoteProvider

updateQuote

protected void updateQuote()

askQuote

public double askQuote()
Specified by:
askQuote in interface Auctioneer
Returns:
the ask market quote.

bidQuote

public double bidQuote()
Specified by:
bidQuote in interface Auctioneer
Returns:
the bid market quote.

clear

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

Specified by:
clear in interface Auctioneer

clear

protected void clear(Shout ask,
                     Shout bid,
                     double price)

determineClearingPrice

public double determineClearingPrice(Shout bid,
                                     Shout ask,
                                     MarketQuote clearingQuote)

eventOccurred

public void eventOccurred(AuctionEvent event)
Specified by:
eventOccurred in interface AuctionEventListener

processGameOver

protected void processGameOver(GameOverEvent event)

processDayClosed

protected void processDayClosed(DayClosedEvent event)

processShoutPlaced

protected void processShoutPlaced(ShoutPlacedEvent event)
caches all the successfully placed shout in shouts.

Parameters:
event -

processTransactionExecuted

protected void processTransactionExecuted(TransactionExecutedEvent event)

processTransactionRejected

protected void processTransactionRejected(TransactionRejectedEvent event)

toString

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