net.sourceforge.jasa.market
Class Order

java.lang.Object
  extended by net.sourceforge.jasa.market.Order
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable<Order>

public class Order
extends java.lang.Object
implements java.lang.Comparable<Order>, java.lang.Cloneable, java.io.Serializable

A class representing an order in an market. An order may be either a bid (offer to buy) or an ask (offer to sell).

Orders are mutable within this package for performance reasons, hence care should be taken not to rely on, e.g. shouts held in collections remaining constant.

See Also:
Serialized Form
 

Field Summary
protected  TradingAgent agent
          The agent placing this order.
protected  Order child
          The child of this order.
protected  boolean isBid
          True if this order is a bid.
protected  double price
          The price of this offer.
protected  int quantity
          The volume of this order.
protected  SimulationTime timeStamp
          The time that this order was placed.
 
Constructor Summary
Order()
           
Order(Order existing)
           
Order(TradingAgent agent)
           
Order(TradingAgent agent, int quantity, double price, boolean isBid)
           
Order(TradingAgent agent, int quantity, double price, boolean isBid, SimulationTime timeStamp)
           
 
Method Summary
 java.lang.Object clone()
           
 int compareTo(Order other)
           
 void copyFrom(Order other)
           
 TradingAgent getAgent()
           
 Order getChild()
          Get the child of this shout.
 double getPrice()
           
 int getQuantity()
           
 SimulationTime getTimeStamp()
           
 boolean isAsk()
           
 boolean isBid()
           
 boolean isValid()
           
 boolean matches(Order other)
          Check whether two orders "cross"; that is, check whether this order could potentially be matched against the supplied order resulting in a transaction.
static double maxPrice(Order s1, Order s2)
           
static double minPrice(Order s1, Order s2)
           
 void setAgent(TradingAgent agent)
           
 void setIsBid(boolean isBid)
           
 void setPrice(double price)
           
 void setQuantity(int quantity)
           
 void setTimeStamp(SimulationTime timeStamp)
           
 java.lang.String toPrettyString()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

quantity

protected int quantity
The volume of this order.


price

protected double price
The price of this offer.


agent

protected TradingAgent agent
The agent placing this order.


isBid

protected boolean isBid
True if this order is a bid. False if this order is an ask.


timeStamp

protected SimulationTime timeStamp
The time that this order was placed.


child

protected Order child
The child of this order.

Constructor Detail

Order

public Order(TradingAgent agent,
             int quantity,
             double price,
             boolean isBid)

Order

public Order(TradingAgent agent,
             int quantity,
             double price,
             boolean isBid,
             SimulationTime timeStamp)

Order

public Order(Order existing)

Order

public Order(TradingAgent agent)

Order

public Order()
Method Detail

getQuantity

public int getQuantity()

getPrice

public double getPrice()

getAgent

public TradingAgent getAgent()

isBid

public boolean isBid()

isAsk

public boolean isAsk()

matches

public boolean matches(Order other)
Check whether two orders "cross"; that is, check whether this order could potentially be matched against the supplied order resulting in a transaction.


compareTo

public int compareTo(Order other)
Specified by:
compareTo in interface java.lang.Comparable<Order>

isValid

public boolean isValid()

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

toString

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

toPrettyString

public java.lang.String toPrettyString()

maxPrice

public static double maxPrice(Order s1,
                              Order s2)

minPrice

public static double minPrice(Order s1,
                              Order s2)

getChild

public Order getChild()
Get the child of this shout. Shouts have children when they are split().

Returns:
The child Shout object, or null if this Shout is childless.

copyFrom

public void copyFrom(Order other)

setIsBid

public void setIsBid(boolean isBid)

setAgent

public void setAgent(TradingAgent agent)

setPrice

public void setPrice(double price)

setQuantity

public void setQuantity(int quantity)

getTimeStamp

public SimulationTime getTimeStamp()

setTimeStamp

public void setTimeStamp(SimulationTime timeStamp)