com.teraspaces.qwfix.ordermanager
Class FIXCrossOrder

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

public final class FIXCrossOrder
extends FIXOrder

Represents an order of a cross order. A FIXCrossOrder is a FIXOrder with a FIXOrderType as CROSS.


Method Summary
 void addOrderCancelRequest(FIXMessage cancelRequest)
          Adds a pending cancel order message to the current order by sending it to the counter party.
 void addOrderReplaceRequest(FIXMessage replaceRequest)
          Adds a pending replace order message to the current order by sending it to the counter party.
 FIXMessage createOrderCancelRequest()
          Used by buy side application to create a Cross Order Cancel Request FIX message.
 FIXMessage createOrderReplaceRequest()
          Used by buy side application to create a Cross Order Cancel/Replace Request FIX message.
 FIXMessage getCurrentOrder()
          Gets the current order.
 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.
 FIXMessage getPendingRequestMessage(int index)
          Gets the pending request FIX message by index.
 int getPendingRequestsCount()
          Gets count of pending request FIX messages.
 FIXMessage getRootOrder()
          Gets the root order.
 FIXRegularOrder getSide1()
          Gets the first side of current cross order.
 FIXRegularOrder getSide2()
          Gets the second side of current cross order.
 boolean isActive()
          Gets a value indicating whether the current order is active.
 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
 
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

addOrderCancelRequest

public void addOrderCancelRequest(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 createOrderCancelRequest() 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.

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

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 - an "Cross Order Cancel Request" FIX message created by calling createOrderCancelRequest() on the same order.

addOrderReplaceRequest

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

The input replaceRequest message must be created by calling createOrderCancelRequest() 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.

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

Before the message is sent, additional Visual Lambda modules and FIXSessionOrderManagerBuySideListener.orderReplaceRequestSending(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:
replaceRequest - a "Cross Order Cancel/Replace Request" FIX message created by calling @link #createOrderReplaceRequest()} on the same order

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)

createOrderCancelRequest

public FIXMessage createOrderCancelRequest()
Used by buy side application to create a Cross Order Cancel Request FIX message.

FIXSessionOrderManagerSchemaSettings.getTagCopyMapCrossOrderCancelRequest() will be used to copy tags.

Application still need to fill in some additional tags such as a new CrossID.

Application is responsible for generating the repeating group for each side of the cross order.

Returns:
a "Cross Order Cancel Request" message

createOrderReplaceRequest

public FIXMessage createOrderReplaceRequest()
Used by buy side application to create a Cross Order Cancel/Replace Request FIX message.

FIXSessionOrderManagerSchemaSettings.getTagCopyMapCrossOrderReplaceRequest() will be used to copy tags.

Application still need to fill in some additional tags such as a new CrossID.

Application is responsible for generating the repeating group for each side of the cross order.

Returns:
a "Cross Order Cancel/Replace Request" message

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

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)

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()

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)

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()

getSide1

public FIXRegularOrder getSide1()
Gets the first side of current cross order.

The cross order will be automatically populated into one or two FIXRegularOrder (depending on the type of cross order). Each FIXRegular represents one side defined in the cross order. The populated side order will have an FIXOrderType of CROSS_POPULATED.

Returns:
the first side

getSide2

public FIXRegularOrder getSide2()
Gets the second side of current cross order.

The cross order will be automatically populated into one or two FIXRegularOrder (depending on the type of cross order). Each FIXRegular represents one side defined in the cross order. The populated side order will have an FIXOrderType of CROSS_POPULATED.

Returns:
the second side; or null if second side is not defined

getCurrentOrder

public FIXMessage getCurrentOrder()
Gets the current order.

Returns:
the current order FIX message

getRootOrder

public FIXMessage getRootOrder()
Gets the root order.

Returns:
the root order FIX message