edu.cuny.cat
Class TraderClient

java.lang.Object
  extended by edu.cuny.cat.GameClient
      extended by edu.cuny.cat.TraderClient
All Implemented Interfaces:
ConnectionListener<CatpMessage>, AuctionEventListener, edu.cuny.config.param.Parameterizable, java.lang.Runnable, java.util.Observer

public class TraderClient
extends GameClient
implements java.util.Observer

Main class of a trader client, used to launch a single such client. To start a jcat competition simulation with game server and multiple clients, the Game class should be used and in this case, TraderClient is involved but not as a main class.

A trader client creates a TradingAgent to choose markets and determine prices to offer.

Version:
$Revision: 1.88 $
Author:
Kai Cai

Nested Class Summary
protected  class TraderClient.TransactionSession
           
 
Nested classes/interfaces inherited from class edu.cuny.cat.GameClient
GameClient.CheckInSession, GameClient.DayClosedSession, GameClient.GameOverSession, GameClient.GameStartedSession, GameClient.GameStartingSession, GameClient.OracleSession, GameClient.PostAskSession, GameClient.PostBidSession, GameClient.PostClientListSession, GameClient.PostFeeSession, GameClient.PostProfitSession, GameClient.PostSession, GameClient.PostShoutSession, GameClient.PostSpecialistSession, GameClient.PostTraderSession, GameClient.PostTransactionSession, GameClient.RoundClosedSession, GameClient.RoundClosingSession, GameClient.RoundOpenedSession, GameClient.SubscribeToSpecialistSession, GameClient.SyncSession
 
Field Summary
protected  TradingAgent agent
          the trading agent that bids and chooses markets for this client.
protected  Shout currentShout
          currently placed or pending shout if null, no such shout.
protected  Specialist registeredSpecialist
          the specialist this trader registers with on the current day
protected  Trader trader
          this client as a Trader.
 
Fields inherited from class edu.cuny.cat.GameClient
clientConnector, clientId, connection, connTrialMax, dispatcher, eventEngine, eventListeners, infrast, logging, P_CONNECTION_TRIAL_MAX, P_DEF_BASE, P_ID, P_LOGGING, P_REPORT, P_TYPE, prng, proactiveSessions, reactiveSessions, registry, report, tag, type
 
Constructor Summary
TraderClient()
           
 
Method Summary
 ClientRegistry createRegistry()
           
 void eventOccurred(AuctionEvent event)
           
 TradingAgent getAgent()
           
protected  CatpReactiveSession getDayOpenedSessionInstance()
           
protected  CatpReactiveSession getDayOpeningSessionInstance()
           
static void main(java.lang.String[] args)
          for starting trader clients alone, separating from market clients and server
protected  void postTransactionReceived(Transaction transaction)
          This method should be implemented by TraderClient and MarketClient respectively to check the validity of the posted transaction.
 void setup(edu.cuny.config.param.ParameterDatabase parameters, edu.cuny.config.param.Parameter base)
           
 void update(java.util.Observable source, java.lang.Object arg)
           
 
Methods inherited from class edu.cuny.cat.GameClient
addAuctionEventListener, addEventDispatchingTask, addReport, checkAndUpdateMatchedShout, cleanUpDaily, cleanUpGamely, clearPendingProactiveSessions, close, connectToServer, createMatchedShoutSimple, dectedAndRunReactiveSessions, dispatchEvent, getId, getReport, getType, loginfo, messageArrived, printDayInfo, printGameInfo, printRoundInfo, processEventDispatchingTasks, removeAuctionEventListener, reportDynamics, reportDynamics, run, setExpectedReactiveSession, setExpectedReactiveSessions, setId, setReport, setType, showSessions, startProactiveSession, testMarketTimeout, testTimeout, testTraderTimeout, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

agent

protected TradingAgent agent
the trading agent that bids and chooses markets for this client.


trader

protected Trader trader
this client as a Trader.


registeredSpecialist

protected Specialist registeredSpecialist
the specialist this trader registers with on the current day


currentShout

protected Shout currentShout
currently placed or pending shout if null, no such shout.

Constructor Detail

TraderClient

public TraderClient()
Method Detail

createRegistry

public ClientRegistry createRegistry()
Specified by:
createRegistry in class GameClient

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
Overrides:
setup in class GameClient

getAgent

public TradingAgent getAgent()

update

public void update(java.util.Observable source,
                   java.lang.Object arg)
Specified by:
update in interface java.util.Observer
Overrides:
update in class GameClient

getDayOpeningSessionInstance

protected CatpReactiveSession getDayOpeningSessionInstance()
Specified by:
getDayOpeningSessionInstance in class GameClient

getDayOpenedSessionInstance

protected CatpReactiveSession getDayOpenedSessionInstance()
Specified by:
getDayOpenedSessionInstance in class GameClient

postTransactionReceived

protected void postTransactionReceived(Transaction transaction)
Description copied from class: GameClient
This method should be implemented by TraderClient and MarketClient respectively to check the validity of the posted transaction.

Specified by:
postTransactionReceived in class GameClient
Parameters:
transaction - the posted transaction

eventOccurred

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

main

public static void main(java.lang.String[] args)
for starting trader clients alone, separating from market clients and server

Parameters:
args -