Class Order
java.lang.Object
eds.model.Order
- All Implemented Interfaces:
ISimulationEntity
Represents a trading order flowing through the simulation.
An order contains both immutable attributes defined at submission and mutable state that changes during execution.
- Immutable attributes: side, type, price, original size, arrival time
- Mutable state: remaining size, execution status, and conclusion time
Lifecycle:
NEW → PARTIAL → FILLED
↘
CANCELLED
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe side of the order.static enumCurrent execution status of the order.static enumThe type of order. -
Constructor Summary
ConstructorsConstructorDescriptionOrder(Order.Side side, Order.Type type, double price, int size, double arrivalTime) Creates a new order instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel(double currentTime) Cancels the order if it is still active.doubleReturns the simulation timestamp when the order arrived.doubleReturns the simulation timestamp when the order finished execution.getId()Returns the unique identifier of this order.intReturns the original share quantity submitted with the order.doublegetPrice()Returns the limit price of the order.intReturns the remaining shares yet to be executed.getSide()Returns the side of the order.Returns the current execution status of the order.getType()Returns the order type.booleanisActive()Determines whether the order is still active in the market.booleanisFilled()Determines whether the order has been fully executed.voidreduceShareSize(int qty, double currentTime) Reduces the remaining share size after a trade execution.toString()Returns a formatted string representation of the order.
-
Constructor Details
-
Order
Creates a new order instance.- Parameters:
side- the order side (BUY or SELL)type- the order type (MARKET or LIMIT)price- the limit price; ignored for MARKET orderssize- the number of shares in the orderarrivalTime- the simulation timestamp when the order arrived
-
-
Method Details
-
getId
-
getSide
-
getType
-
getPrice
public double getPrice()Returns the limit price of the order.For
Order.Type.MARKETorders this value is ignored by the matching engine.- Returns:
- the order price
-
getStatus
Returns the current execution status of the order.- Returns:
- the order status
-
getArrivalTime
public double getArrivalTime()Returns the simulation timestamp when the order arrived.- Returns:
- the arrival time
-
getConclusionTime
public double getConclusionTime()Returns the simulation timestamp when the order finished execution.If the order has not yet completed, this value will be
Double.NaN.- Returns:
- the conclusion time
-
isActive
public boolean isActive()Determines whether the order is still active in the market.- Returns:
trueif the order status isOrder.Status.NEWorOrder.Status.PARTIAL, otherwisefalse
-
isFilled
public boolean isFilled()Determines whether the order has been fully executed.- Returns:
trueif the status isOrder.Status.FILLED
-
cancel
public void cancel(double currentTime) Cancels the order if it is still active.The order status becomes
Order.Status.CANCELLEDand the conclusion time is recorded.- Parameters:
currentTime- the simulation timestamp of the cancellation
-
toString
-