celeboss.bot
Class AbstractRobotTrader

java.lang.Object
  extended byceleboss.bot.AbstractRobotTrader
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, RobotTrader

public abstract class AbstractRobotTrader
extends java.lang.Object
implements java.awt.event.ActionListener, RobotTrader

This class provides a skeleton for any automated trader to be constructed on top of. The class provides a top-level window with buttons to control the robots progress. There is also a means to log messages and display the status of the robot. It contains a log area where messages concerning the progress can be recorded.

Version:
1.0
Author:
bevans

Field Summary
static int ERROR
          Value of the Error status
static int RUNNING
          Value of the Running status
static int STARTING
          Value of the Starting status
static int STOPPED
          Value of the Stopped status
static int STOPPING
          Value of the Stopping status
static int WAITING
          Value of the Waiting status
 
Constructor Summary
protected AbstractRobotTrader(java.lang.String newName)
          Create the basic window framework for the robot to be hosted.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent arg0)
          An action has been performed in one of the child components.
 void logMessage(java.lang.String message)
          Log a new message to the log area.
 void setContext(Portfolio portfolio)
          Set the context in which this Bot is suppose to work.
protected  void setContextPane(javax.swing.JPanel contentPane)
          A context pane for the specific sub-class robot is specified.
 void setStatus(int state, java.lang.String message)
          Update the status of this robot.
protected  void setTimePrefix(boolean newPrefix)
          This method defines whether the logged messages should be prefixed with a date and time of their entry.
 void shutdown()
          This method shoudl be overridden by any sub-classes.
abstract  boolean start()
          The robot is to start processing.
abstract  void stop()
          The robot is to stop processing immediately.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final int ERROR
Value of the Error status

See Also:
Constant Field Values

RUNNING

public static final int RUNNING
Value of the Running status

See Also:
Constant Field Values

STARTING

public static final int STARTING
Value of the Starting status

See Also:
Constant Field Values

STOPPED

public static final int STOPPED
Value of the Stopped status

See Also:
Constant Field Values

STOPPING

public static final int STOPPING
Value of the Stopping status

See Also:
Constant Field Values

WAITING

public static final int WAITING
Value of the Waiting status

See Also:
Constant Field Values
Constructor Detail

AbstractRobotTrader

protected AbstractRobotTrader(java.lang.String newName)
Create the basic window framework for the robot to be hosted.

Parameters:
newName - Name of robot.
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg0)
An action has been performed in one of the child components.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
arg0 - Description of event.

logMessage

public final void logMessage(java.lang.String message)
Log a new message to the log area.

Parameters:
message - New message to log.

setContext

public void setContext(Portfolio portfolio)
Set the context in which this Bot is suppose to work. This method should be overridden by any subclass to set-up the robot. Any sub-class must invoked this method at the end of the context.

Specified by:
setContext in interface RobotTrader
Parameters:
portfolio - The portfolio to be traded

setContextPane

protected final void setContextPane(javax.swing.JPanel contentPane)
A context pane for the specific sub-class robot is specified. It allows the robot to provide extrat custom components that may control the algorithm. This method can be invoked during a sub-class constructor; it must be invoked once the object has been correctly constructed.

Parameters:
contentPane - Panel containing robot specific content.

setStatus

public final void setStatus(int state,
                            java.lang.String message)
Update the status of this robot. This will trigger the updating of the status bar and the enabled buttons

Parameters:
state - State must be between WAITING and ERROR.
message - Optional extra message.

setTimePrefix

protected void setTimePrefix(boolean newPrefix)
This method defines whether the logged messages should be prefixed with a date and time of their entry. Setting this true can be very useful for robots that execute over a long period of time.

Parameters:
newPrefix - New prefix setting.
See Also:
logMessage(String)

shutdown

public void shutdown()
This method shoudl be overridden by any sub-classes. The sub-classes must still invoke this method once the local shutdown has been completed.

Specified by:
shutdown in interface RobotTrader

start

public abstract boolean start()
The robot is to start processing. Any longer term processing resulting this method should be performed via a Thread or Runnable.

Returns:
Has the robot been successfuly started.

stop

public abstract void stop()
The robot is to stop processing immediately. It may be re-started later via the start method.