net.sourceforge.jasa.agent
Class TokenTradingAgent

java.lang.Object
  extended by AbstractAgent
      extended by net.sourceforge.jasa.agent.AbstractTradingAgent
          extended by net.sourceforge.jasa.agent.FixedDirectionTradingAgent
              extended by net.sourceforge.jasa.agent.TokenTradingAgent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, TradingAgent, MarketEventListener

public class TokenTradingAgent
extends FixedDirectionTradingAgent
implements java.io.Serializable

Agents of this type have a finite trade entitlement, which determines how many units or "tokens" they are able to trade in a given trading period. Agents become inactive once their intitial trade entitlement is used up, and their trade entitlement is restored at the end of each day.

 

Field Summary
protected  int initialTradeEntitlement
          The initial value of tradeEntitlement
protected  boolean isActive
           
protected  int quantityTraded
          The number of units traded to date
protected  int tradeEntitlement
          The number of units this agent is entitlted to trade in this trading period.
 
Fields inherited from class net.sourceforge.jasa.agent.AbstractTradingAgent
account, currentOrder, group, initialFunds, initialStock, lastOrderFilled, lastPayoff, markets, stock, totalPayoff, utilityFunction, valuer
 
Constructor Summary
TokenTradingAgent()
           
TokenTradingAgent(double privateValue, int tradeEntitlement, EventScheduler scheduler)
           
TokenTradingAgent(EventScheduler scheduler)
           
TokenTradingAgent(int stock, double funds, double privateValue, int tradeEntitlement, EventScheduler scheduler)
           
 
Method Summary
 boolean active()
          Determine whether or not this trader is active.
 int determineQuantity(Market auction)
           
 double equilibriumProfits(Market auction, double equilibriumPrice, int quantity)
          Calculate the hypothetical surplus this agent will receive if the market had cleared uniformly at the specified equilibrium price and quantity.
 double equilibriumProfitsEachDay(Market auction, double equilibriumPrice, int quantity)
           
 int getInitialTradeEntitlement()
           
 int getQuantityTraded()
           
 int getTradeEntitlement()
           
 void initialise()
           
 void onAgentArrival(Market auction, AgentArrivalEvent event)
          Place an order in the market as determined by the agent's strategy.
 void onEndOfDay(MarketEvent event)
           
 void orderFilled(Market auction, Order shout, double price, int quantity)
           
 java.lang.Object protoClone()
           
 void setInitialTradeEntitlement(int initialTradeEntitlement)
           
 void setTradeEntitlement(int tradeEntitlement)
           
 java.lang.String toString()
           
 
Methods inherited from class net.sourceforge.jasa.agent.FixedDirectionTradingAgent
getStrategy, isBuyer, isSeller, setIsBuyer, setIsSeller, setStrategy
 
Methods inherited from class net.sourceforge.jasa.agent.AbstractTradingAgent
calculatePayoff, calculateProfit, clone, eventOccurred, getAccount, getCommodityHolding, getCurrentOrder, getFunds, getGroup, getLastPayoff, getMarket, getMarkets, getPayoff, getStock, getTotalPayoff, getTradingStrategy, getUtilityFunction, getValuation, getValuationPolicy, getVolume, giveFunds, isBuyer, isInteracted, isSeller, lastOrderFilled, onAgentArrival, onMarketClosed, onMarketOpen, pay, register, reset, setGroup, setMarket, setMarkets, setPrivateValue, setUtilityFunction, setValuationPolicy, subscribeToEvents
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

tradeEntitlement

protected int tradeEntitlement
The number of units this agent is entitlted to trade in this trading period.


initialTradeEntitlement

protected int initialTradeEntitlement
The initial value of tradeEntitlement


quantityTraded

protected int quantityTraded
The number of units traded to date


isActive

protected boolean isActive
Constructor Detail

TokenTradingAgent

public TokenTradingAgent(EventScheduler scheduler)

TokenTradingAgent

public TokenTradingAgent()

TokenTradingAgent

public TokenTradingAgent(int stock,
                         double funds,
                         double privateValue,
                         int tradeEntitlement,
                         EventScheduler scheduler)

TokenTradingAgent

public TokenTradingAgent(double privateValue,
                         int tradeEntitlement,
                         EventScheduler scheduler)
Method Detail

protoClone

public java.lang.Object protoClone()
Overrides:
protoClone in class AbstractTradingAgent

onAgentArrival

public void onAgentArrival(Market auction,
                           AgentArrivalEvent event)
Description copied from class: AbstractTradingAgent
Place an order in the market as determined by the agent's strategy.

Overrides:
onAgentArrival in class AbstractTradingAgent

initialise

public void initialise()
Overrides:
initialise in class AbstractTradingAgent

onEndOfDay

public void onEndOfDay(MarketEvent event)
Overrides:
onEndOfDay in class AbstractTradingAgent

active

public boolean active()
Description copied from class: AbstractTradingAgent
Determine whether or not this trader is active. Inactive traders do not place shouts in the market, but do carry on learning through their strategy.

Overrides:
active in class FixedDirectionTradingAgent
Returns:
true if the trader is active.

orderFilled

public void orderFilled(Market auction,
                        Order shout,
                        double price,
                        int quantity)
Specified by:
orderFilled in interface TradingAgent
Overrides:
orderFilled in class AbstractTradingAgent

equilibriumProfits

public double equilibriumProfits(Market auction,
                                 double equilibriumPrice,
                                 int quantity)
Description copied from class: AbstractTradingAgent
Calculate the hypothetical surplus this agent will receive if the market had cleared uniformly at the specified equilibrium price and quantity.

Overrides:
equilibriumProfits in class AbstractTradingAgent

equilibriumProfitsEachDay

public double equilibriumProfitsEachDay(Market auction,
                                        double equilibriumPrice,
                                        int quantity)
Overrides:
equilibriumProfitsEachDay in class AbstractTradingAgent

getQuantityTraded

public int getQuantityTraded()

determineQuantity

public int determineQuantity(Market auction)
Overrides:
determineQuantity in class AbstractTradingAgent

getTradeEntitlement

public int getTradeEntitlement()

setTradeEntitlement

public void setTradeEntitlement(int tradeEntitlement)

getInitialTradeEntitlement

public int getInitialTradeEntitlement()

setInitialTradeEntitlement

public void setInitialTradeEntitlement(int initialTradeEntitlement)

toString

public java.lang.String toString()