com.teraspaces.qwfix.ordermanager
Class FIXListOrder

java.lang.Object
  extended by com.teraspaces.qwfix.ordermanager.FIXOrder
      extended by com.teraspaces.qwfix.ordermanager.FIXListOrder

public final class FIXListOrder
extends FIXOrder

Represents an order of a list order. A cross order is a FIXOrder with a FIXOrderType as LIST.


Method Summary
 void addListCancelRequest(FIXMessage cancelRequest)
          Adds a pending cancel order message to the current order by sending it to the counter party.
 void addListExecute(FIXMessage executeMessage)
          Notifies the counter party to execute the list order by sending the specified "List Execute" message.
 void addListStatus(FIXMessage[] reportMessages)
          Adds the list status.
 void addListStatusRequest(FIXMessage statusReqMessage)
          Adds a status request message to the current order by sending it to the counter party.
 FIXMessage createListCancelRequest()
          Creates the "List Cancel Request" FIX message.
 FIXMessage createListExecute()
          Creates the list execute.
 FIXMessage createListStatus(int listStatusType, int listOrderStatus)
          Creates the "List Status" FIX message.
 FIXMessage createListStatusRequest()
          Creates the "List Status Request" FIX message.
 FIXMessage getListCancelRequestMessage()
          Gets the "List Cancel Request" FIX message.
 FIXMessage getListExecuteMessage()
          Gets the list execute message.
 String getListID()
          Gets the ListID.
 int getListOrderStatus()
          Gets the list order status.
 FIXMessage getMessage(int index)
          Gets the FIXMessage related to this order by specified index.
 int getMessageCount()
          Gets the number of messages related to the current order.
 FIXRegularOrder getOrder(int index)
          Gets the order by index.
 int getOrderCount()
          Gets the count of orders.
 FIXMessage getPendingRequestMessage(int index)
          Gets the pending request FIX message by index.
 int getPendingRequestsCount()
          Gets count of pending request FIX messages.
 FIXRegularOrder getSingleOrder(String clOrdID)
          Gets the instance of the single order defined in current list order with the specified "ClOrdID" .
 boolean isActive()
          Gets a value indicating whether the current order is active.
 boolean isListCompleted()
          Determines whether the entire list has been transmitted.
 boolean isPendingCancel()
          Gets a value indicating whether the current order is pending cancel.
 boolean isPendingReplace()
          Gets a value indicating whether the current order is pending replace
 void setListOrderStatus(int status)
          Sets the list order status.
 
Methods inherited from class com.teraspaces.qwfix.ordermanager.FIXOrder
getFIXOrderType, getIndex, getSessionOrderList, getSessionOrderManager, getSessionPersistence, getTag, isRestatedGT, setTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isActive

public boolean isActive()
Description copied from class: FIXOrder
Gets a value indicating whether the current order is active.

A FIXRegularOrder is considered active if FIXRegularOrder.getOrdStatus() represents an active state.

A FIXCrossOrder is considered active if any side of the order is active.

A FIXListOrder is considered active if any individual order is active.

Specified by:
isActive in class FIXOrder
Returns:
true if the current order is active; otherwise, false

getMessageCount

public int getMessageCount()
Description copied from class: FIXOrder
Gets the number of messages related to the current order.

Specified by:
getMessageCount in class FIXOrder
Returns:
the message count
See Also:
FIXOrder.getMessage(int)

getMessage

public FIXMessage getMessage(int index)
Description copied from class: FIXOrder
Gets the FIXMessage related to this order by specified index.

Specified by:
getMessage in class FIXOrder
Parameters:
index - the index
Returns:
the message
See Also:
FIXOrder.getMessageCount()

addListStatusRequest

public void addListStatusRequest(FIXMessage statusReqMessage)
Adds a status request message to the current order by sending it to the counter party. Should be used by buy side only.

The input statusReqMessage message must be created by calling createListStatusRequest() on the same list order.

This operation can only be performed on a buy side order and the system must be running in a normal production mode. Otherwise an RuntimeException will be thrown out.

If this operation returns successfully, the status request message is sent, and FIXSessionOrderManagerCommonListener.orderStatusRequestAdded(FIXOrder, FIXMessage, FIXEngineMessageHandlerStatus) event is triggered. See FIXSessionOrderManagerSettings.alwaysSendStatusRequest() for more details about how a status request message can be sent by order manager.

Parameters:
statusReqMessage - a "List Status Request" FIX message created by calling createListStatusRequest() on the same order.

addListCancelRequest

public void addListCancelRequest(FIXMessage cancelRequest)
Adds a pending cancel order message to the current order by sending it to the counter party. Should be used by buy side only.

The input cancelRequest message must be created by calling createListCancelRequest() on the same order.

This operation can only be performed on a buy side order and the system must be running in a normal production mode. Otherwise an RuntimeException will be thrown out.

Before the message is sent, additional Visual Lambda modules and FIXSessionOrderManagerBuySideListener.orderCancelRequestSending(FIXOrder, FIXMessage) event handlers will be called. Application can hook up those handlers to provide further modification to the message (add/delete/modify the fields). Application can also use the handlers to provide further validation for the message. If the message failed the validation, a FIXOrderManagerCancelRejectException will be thrown out and the message will not be sent.

Parameters:
cancelRequest - a "List Cancel Request" FIX message created by calling CreateListCancelRequest()()() on the same order

getPendingRequestMessage

public FIXMessage getPendingRequestMessage(int index)
Description copied from class: FIXOrder
Gets the pending request FIX message by index.

GetPendingRequestMessage does not acquire FIXOrderManager.syncRoot lock.

If the pending order is a cross order cancel or cross order replace request, the return message may contain more one side of the cross order. To get the exact side related to the current order, use FIXRegularOrder.getPendingRequest(int).

Specified by:
getPendingRequestMessage in class FIXOrder
Parameters:
index - the index
Returns:
an instance of FIXMessage representing the pending request
See Also:
FIXOrder.getPendingRequestsCount()

isPendingCancel

public boolean isPendingCancel()
Description copied from class: FIXOrder
Gets a value indicating whether the current order is pending cancel.

isPendingCancel() returns true if there is any cancel request in the pending order list.

An order may have more than 1 pending orders. It's up to the high level business logic to decide whether the pending orders should be processed in time order or reverse time order.

Specified by:
isPendingCancel in class FIXOrder
Returns:
true if the current order is pending cancel; otherwise, false
See Also:
FIXOrder.isPendingReplace(), FIXOrder.getPendingRequestsCount(), FIXOrder.getPendingRequestMessage(int)

isPendingReplace

public boolean isPendingReplace()
Description copied from class: FIXOrder
Gets a value indicating whether the current order is pending replace

isPendingReplace() returns true if there is any replace request in the pending order list.

An order may have more than 1 pending orders. It's up to the high level business logic to decide whether the pending orders should be processed in time order or reverse time order.

Specified by:
isPendingReplace in class FIXOrder
Returns:
true if the current order is pending replace; otherwise, false
See Also:
FIXOrder.isPendingCancel(), FIXOrder.getPendingRequestsCount(), FIXOrder.getPendingRequestMessage(int)

getPendingRequestsCount

public int getPendingRequestsCount()
Description copied from class: FIXOrder
Gets count of pending request FIX messages.

Specified by:
getPendingRequestsCount in class FIXOrder
Returns:
the pending requests count
See Also:
FIXOrder.getPendingRequestMessage(int)

getListID

public String getListID()
Gets the ListID.

Returns:
the ListID

getListOrderStatus

public int getListOrderStatus()
Gets the list order status.

Returns:
the list order status

setListOrderStatus

public void setListOrderStatus(int status)
Sets the list order status.

Parameters:
status - the new list order status

isListCompleted

public boolean isListCompleted()
Determines whether the entire list has been transmitted.

In case fragmentation is used, the list of order will be transmitted across multiple "New Order - List" FIX messages. This method will test if the list has been completed by checking whether each individual orders can be extracted from all messages.

Currently implementation simply checks if there is any "null" in the order list.

Returns:
true if the entire list has been transmitted; otherwise, false

addListStatus

public void addListStatus(FIXMessage[] reportMessages)
                   throws FIXSessionRejectException,
                          IOException
Adds the list status. This method only works for buy side.

This method is called on a sell side session only.

If an exception is thrown out, no message in the report list will be sent to the recipient. In another word, this operation is transactional. Messages are sent in an "all-or-none" fashion.

Parameters:
reportMessages - The list of status report messages (probably segmented).
Throws:
FIXSessionRejectException - the FIX session reject exception
IOException - Signals that an I/O exception has occurred.

addListExecute

public void addListExecute(FIXMessage executeMessage)
Notifies the counter party to execute the list order by sending the specified "List Execute" message.

This operation can only be performed on a buy side list order.

Parameters:
executeMessage - the "List Execute" FIX message.

createListExecute

public FIXMessage createListExecute()
Creates the list execute. The method should be called on buy side session only.

This method creates the "List Execute" message based on the version of the FIX schema and parameters of the original list order (such as ListID, BidID and ClientBidID).

Returns:
an instance of FIXMessage representing the "List Execute" message of the current list order

createListStatusRequest

public FIXMessage createListStatusRequest()
Creates the "List Status Request" FIX message. The method should be called on buy side session only.

Returns:
the "List Status Request" FIX message

createListCancelRequest

public FIXMessage createListCancelRequest()
Creates the "List Cancel Request" FIX message. The method should be called on buy side session only.

Returns:
the "List Cancel Request" FIX message

createListStatus

public FIXMessage createListStatus(int listStatusType,
                                   int listOrderStatus)
Creates the "List Status" FIX message.

The method creates a "List Status" FIX message and add the following 4 fields to it: "ListStatusType", "ListOrderStatus", "ListID" and "TransactTime".

Values of "ListStatusType", "ListOrderStatus" and "TransactTime" will be ignored if the corresponding fields are not defined in the message (e.g. standard FIX 4.1 messages).

Parameters:
listStatusType - the value of "ListStatusType" field
listOrderStatus - the value of "ListOrderStatus" field
Returns:
the fIX message

getListExecuteMessage

public FIXMessage getListExecuteMessage()
Gets the list execute message.

Returns:
the list execute message; or null if no execution message is processed

getListCancelRequestMessage

public FIXMessage getListCancelRequestMessage()
Gets the "List Cancel Request" FIX message.

Returns:
the list cancel request message; or null if no "List Cancel Request" is processed

getOrderCount

public int getOrderCount()
Gets the count of orders.

Returns:
the order count
See Also:
getOrder(int)

getOrder

public FIXRegularOrder getOrder(int index)
Gets the order by index.

Parameters:
index - the index
Returns:
the order
See Also:
getOrderCount()

getSingleOrder

public FIXRegularOrder getSingleOrder(String clOrdID)
Gets the instance of the single order defined in current list order with the specified "ClOrdID" .

If the order is accepted by the sell side (order is not canceled or rejected and "ListExecute" message is sent and accepted), all single orders will be "populated", the order can be retrieved by making call to FIXSessionOrderList.getOrderByClOrdID(String).

However, before "ListExecute" is sent and accepted, the order will not be populated. getOrderByClOrdID(String) will not be able to retrieve the order from the system. Use this method to get the order by linearly searching the single order list of the current list order.

Parameters:
clOrdID - the "ClOrdID" that uniquely identifies the order
Returns:
an instance of FIXRegularOrder that represents the single order; or null if the input ClOrdID is invalid