com.activequant.trading
Interface IOrderTracker


public interface IOrderTracker

Order tracker (normally implemented by IBroker). Allows to get the current state of the order, and attach to the events related to this order.

The order gets physically sent to the broker only after tracker's submit method is called. The purpose of splitting order submission from the order preparation IBroker is to allow user to attach its event handlers and avoid race conditions what events may start flowing before user is prepared to receive them.

Closed orders

Closed orders are orders that are no longer in processing: they have been canceled, rejected, filled, or partially filled and canceled. Tracker interface will throw an exception if user tries to perform actions on a closed order. For a closed order, history property does not change.

What distinguishes tracker that corresponds to a closed order from the one that corresponds to an open order, is the orderCompletion property. For closed orders its not null and gives a convenient summary of the order final state. Note that for closed orders some brokers may not provide detailed execution information, but instead provide only final "gross" view.

Opened orders

Opened orders are the ones that may change asynchronously. Therefore, users must be aware of this "volatile" nature of open orders. For example, orderCompletion being null tells that order has not been completed at the moment when method was called. By the time it returns, it may already be completed! There are two ways to deal with this "volatility" that fit different programming styles: event-oriented processing, and synchronous processing.

To get notified of the order events, application may attach to the tracker's event source. It is better done before submit() was called, so that it is guaranteed that no events has been missed. Then, event-processing code may analyze the message type and content to monitor the order state changes. Note that history in the tracker is updated before event is sent by the tracker. This guarantees that application code sees already updated event history in the event handling code.

Application may choose to wait till the order completes, and then analyze the completion by looking at orderCompletion and/or history properties. There are waitForCompletion methods for doing this.
History:
- [06.12.2007] Created (Mike Kroutikov)

Author:
Mike Kroutikov

Method Summary
 void cancel()
          Cancels this order.
 Order getOrder()
          Original order that initiated this tracker.
 IEventSource<OrderEvent> getOrderEventSource()
          Returns event source for the detailed order-related events.
 String getVenueAssignedId()
          Venue assigned id for this order processing.
 void submit()
          Submits the order.
 void update(Order newOrder)
          Updates pending order.
 

Method Detail

getOrder

Order getOrder()
Original order that initiated this tracker. If there were any updates to the original order, they are NOT reflected here: to find them, one have to track the update events emitted by this object.

Returns:
order.

getVenueAssignedId

String getVenueAssignedId()
Venue assigned id for this order processing.

Returns:
id.

submit

void submit()
Submits the order. Before this method is called, broker-assigned id is not available, and tracker is not registered with the broker (i.e. not returned by IBroker#getOrders()). Events can start flowing only after submit is called. Therefore, attach all your event listeners before submitting the order.

Throws:
Exception

update

void update(Order newOrder)
Updates pending order. Note that not all updates are permitted. Refer to the broker's implementation documentation for more details. If the order has been completed (successfully or not), does nothing.

Parameters:
newOrder - the order to replace the original one.

cancel

void cancel()
Cancels this order. If order has been already completed (successfully or not), does nothing.


getOrderEventSource

IEventSource<OrderEvent> getOrderEventSource()
Returns event source for the detailed order-related events. A special event : OrderCompletionEvent is fired when the order is completed (successfully or not). This event is always the last event fired by broker with respect to this order.

Returns:
order event source.


Copyright © 2012 ActiveQuant GmbH. All Rights Reserved.