edu.cuny.cat.trader
Class AbstractTradingAgent

java.lang.Object
  extended by java.util.Observable
      extended by edu.cuny.cat.trader.AbstractTradingAgent
All Implemented Interfaces:
AuctionEventListener, edu.cuny.config.param.Parameterizable, edu.cuny.obj.Prototypeable, edu.cuny.obj.Resetable, java.io.Serializable, java.lang.Cloneable, java.util.Observer
Direct Known Subclasses:
TradingAgent

public abstract class AbstractTradingAgent
extends java.util.Observable
implements AuctionEventListener, java.io.Serializable, edu.cuny.config.param.Parameterizable, edu.cuny.obj.Prototypeable, java.lang.Cloneable, java.util.Observer, edu.cuny.obj.Resetable

An abstract implementation of trading agents that can bid in a market and can choose between markets to maximize their profit.

Version:
$Revision: 1.63 $
Author:
Kai Cai
See Also:
Serialized Form

Field Summary
protected  java.util.Map<java.lang.String,Specialist> availableMarkets
           
protected  Shout currentShout
          The current shout for this trader.
protected  double informationFee
           
protected  boolean isSeller
          Flag indicating whether this trader is a seller or buyer.
protected  double lastDayProfit
          The profit made in the last day.
protected  double lastShoutProfit
          The profit made in the last accepted shout.
protected  AbstractMarketSelectionStrategy marketSelectionStrategy
           
static java.lang.String P_DEF_BASE
          Parameter names used when initialising from parameter db
static java.lang.String P_INITIAL_MARGIN
           
static java.lang.String P_IS_SELLER
           
static java.lang.String P_MARKET_SELECTION_STRATEGY
           
static java.lang.String P_RESETTING_CONDITION
           
static java.lang.String P_STRATEGY
           
protected  double privateValue
           
protected  double profitFee
           
protected  double profits
          The total cumulativeProfits to date
protected  double registrationFee
           
protected  ResettingCondition resettingCondition
           
protected  double shoutFee
           
protected  java.util.Set<java.lang.String> shoutIdList
           
protected  AbstractStrategy strategy
          The bidding strategy for this trader.
protected  java.lang.String traderId
           
protected  double transactionFee
           
 
Constructor Summary
AbstractTradingAgent()
           
AbstractTradingAgent(double privateValue, boolean isSeller)
           
AbstractTradingAgent(double privateValue, boolean isSeller, AbstractStrategy strategy)
           
 
Method Summary
 void eventOccurred(AuctionEvent event)
           
 Shout getCurrentShout()
           
 double getLastDayProfit()
           
 double getLastShoutProfit()
           
 AbstractMarketSelectionStrategy getMarketSelectionStrategy()
           
 double getPrivateValue()
           
 double getProfits()
           
 AbstractStrategy getStrategy()
           
 java.lang.String getTraderId()
           
 void initialize()
           
abstract  boolean isActive()
           
 boolean isBuyer()
           
 boolean isSeller()
           
 void processDayClosed(DayClosedEvent event)
           
 void processDayOpened(DayOpenedEvent event)
           
 void processFeesAnnounced(FeesAnnouncedEvent event)
           
 void processGameOver(GameOverEvent event)
           
 void processGameStarted(GameStartedEvent event)
           
 void processGameStarting(GameStartingEvent event)
           
protected  void processIdAssigned(IdAssignedEvent event)
           
 void processPrivateValueAssigned(PrivateValueAssignedEvent event)
           
 void processRegistration(RegistrationEvent event)
           
 void processRoundClosed(RoundClosedEvent event)
           
protected  void processRoundClosing(RoundClosingEvent event)
           
 void processRoundOpened(RoundOpenedEvent event)
           
 void processShoutPlaced(ShoutPlacedEvent event)
           
 void processSubscription(SubscriptionEvent event)
           
 void processTransactionExecuted(TransactionExecutedEvent event)
           
 void requestShout()
           
 void reset()
           
 void setIsSeller(boolean isSeller)
           
 void setLastDayProfit(double lastDayProfit)
           
 void setLastShoutProfit(double lastShoutProfit)
           
 void setMarketSelectionStrategy(AbstractMarketSelectionStrategy marketSelectionStrategy)
           
 void setPrivateValue(double privateValue)
           
 void setProfits(double profits)
           
 void setStrategy(AbstractStrategy strategy)
           
 void setTraderId(java.lang.String traderId)
           
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 void shoutAccepted(Shout shout, double price, int quantity)
           
 void update(java.util.Observable o, java.lang.Object arg)
          used by various strategies or conditions to notify trader client to register, subscribe, or reset
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface edu.cuny.obj.Prototypeable
protoClone
 

Field Detail

privateValue

protected double privateValue

isSeller

protected boolean isSeller
Flag indicating whether this trader is a seller or buyer.


strategy

protected AbstractStrategy strategy
The bidding strategy for this trader. The default strategy is to bid truthfully for a single unit.


marketSelectionStrategy

protected AbstractMarketSelectionStrategy marketSelectionStrategy

resettingCondition

protected ResettingCondition resettingCondition

lastShoutProfit

protected double lastShoutProfit
The profit made in the last accepted shout.


lastDayProfit

protected double lastDayProfit
The profit made in the last day.


profits

protected double profits
The total cumulativeProfits to date


currentShout

protected Shout currentShout
The current shout for this trader.


traderId

protected java.lang.String traderId

availableMarkets

protected java.util.Map<java.lang.String,Specialist> availableMarkets

shoutIdList

protected java.util.Set<java.lang.String> shoutIdList

registrationFee

protected double registrationFee

informationFee

protected double informationFee

shoutFee

protected double shoutFee

transactionFee

protected double transactionFee

profitFee

protected double profitFee

P_DEF_BASE

public static final java.lang.String P_DEF_BASE
Parameter names used when initialising from parameter db

See Also:
Constant Field Values

P_IS_SELLER

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

P_STRATEGY

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

P_INITIAL_MARGIN

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

P_MARKET_SELECTION_STRATEGY

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

P_RESETTING_CONDITION

public static final java.lang.String P_RESETTING_CONDITION
See Also:
Constant Field Values
Constructor Detail

AbstractTradingAgent

public AbstractTradingAgent()

AbstractTradingAgent

public AbstractTradingAgent(double privateValue,
                            boolean isSeller)

AbstractTradingAgent

public AbstractTradingAgent(double privateValue,
                            boolean isSeller,
                            AbstractStrategy strategy)
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

initialize

public void initialize()

reset

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

shoutAccepted

public void shoutAccepted(Shout shout,
                          double price,
                          int quantity)

requestShout

public void requestShout()

eventOccurred

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

processIdAssigned

protected void processIdAssigned(IdAssignedEvent event)

processFeesAnnounced

public void processFeesAnnounced(FeesAnnouncedEvent event)

processRegistration

public void processRegistration(RegistrationEvent event)

processGameStarting

public void processGameStarting(GameStartingEvent event)

processGameStarted

public void processGameStarted(GameStartedEvent event)

processGameOver

public void processGameOver(GameOverEvent event)

processRoundOpened

public void processRoundOpened(RoundOpenedEvent event)

processRoundClosing

protected void processRoundClosing(RoundClosingEvent event)

processRoundClosed

public void processRoundClosed(RoundClosedEvent event)

processDayClosed

public void processDayClosed(DayClosedEvent event)

processDayOpened

public void processDayOpened(DayOpenedEvent event)

processPrivateValueAssigned

public void processPrivateValueAssigned(PrivateValueAssignedEvent event)

processTransactionExecuted

public void processTransactionExecuted(TransactionExecutedEvent event)

processSubscription

public void processSubscription(SubscriptionEvent event)

processShoutPlaced

public void processShoutPlaced(ShoutPlacedEvent event)

getTraderId

public java.lang.String getTraderId()

setPrivateValue

public void setPrivateValue(double privateValue)

getPrivateValue

public double getPrivateValue()

getCurrentShout

public Shout getCurrentShout()

setIsSeller

public void setIsSeller(boolean isSeller)

isSeller

public boolean isSeller()

isBuyer

public boolean isBuyer()

setTraderId

public void setTraderId(java.lang.String traderId)

setStrategy

public void setStrategy(AbstractStrategy strategy)

getStrategy

public AbstractStrategy getStrategy()

setMarketSelectionStrategy

public void setMarketSelectionStrategy(AbstractMarketSelectionStrategy marketSelectionStrategy)

getMarketSelectionStrategy

public AbstractMarketSelectionStrategy getMarketSelectionStrategy()

getProfits

public double getProfits()

setProfits

public void setProfits(double profits)

getLastDayProfit

public double getLastDayProfit()

setLastDayProfit

public void setLastDayProfit(double lastDayProfit)

getLastShoutProfit

public double getLastShoutProfit()

setLastShoutProfit

public void setLastShoutProfit(double lastShoutProfit)

isActive

public abstract boolean isActive()
Returns:
true if this trading agent is actively trading or false otherwise.

update

public void update(java.util.Observable o,
                   java.lang.Object arg)
used by various strategies or conditions to notify trader client to register, subscribe, or reset

Specified by:
update in interface java.util.Observer