public class TradeOrder
extends java.lang.Object
Constructor and Description |
---|
TradeOrder(Trader trader,
java.lang.String symbol,
boolean buyOrder,
boolean marketOrder,
int numShares,
double price)
Constructs a new
TradeOrder for a given trader, stock symbol,
a number of shares, and other parameters. |
Modifier and Type | Method and Description |
---|---|
double |
getPrice()
Returns the price per share for this trade order (used by a limit order).
|
int |
getShares()
Returns the number of shares to be traded in this trade order.
|
java.lang.String |
getSymbol()
Returns the stock symbol for this trade order.
|
Trader |
getTrader()
Returns the trader for this trade order.
|
boolean |
isBuy()
Returns true if this is a buy order; otherwise returns false.
|
boolean |
isLimit()
Returns true if this is a limit order; otherwise returns false.
|
boolean |
isMarket()
Returns true if this is a market order; otherwise returns false.
|
boolean |
isSell()
Returns true if this is a sell order; otherwise returns false.
|
void |
subtractShares(int shares)
Subtracts a given number of shares from the
total number of shares in this trade order.
|
public TradeOrder(Trader trader, java.lang.String symbol, boolean buyOrder, boolean marketOrder, int numShares, double price)
TradeOrder
for a given trader, stock symbol,
a number of shares, and other parameters.trader
- a trader who placed this order.symbol
- stock symbol.buyOrder
- if true this is a buy order; otherwise this is a sell order.marketOrder
- if true this is a market order; otherwise this is a limit order.numShares
- the number of shares to be traded.price
- the bid or ask price, if this is a limit order.public Trader getTrader()
public java.lang.String getSymbol()
public boolean isBuy()
public boolean isSell()
public boolean isMarket()
public boolean isLimit()
public int getShares()
public double getPrice()
public void subtractShares(int shares)
shares
- a number of shares to be subtracted.java.lang.IllegalArgumentException
- if shares is greater than
the number of shares
in this order.