Get Latest Order Information From Last Execution

The latest information about the order (such as CumQty, AvgPx etc) should be retrieved from the last execution report.

Note: The last execution might be null, which means that the system has not received any execution against the order yet.

For more information about thread safety, please read "Thread Safety".

    // Prerequisites: Variable "order" of type FIXRegularOrder.
    FIXMessageComponent lastExecMsg = order.getLastExecution();
    double cumQty;
    double avgPx;
    if (lastExecMsg == null) {
        cumQty = avgPx = 0;
    else {
        cumQty = lastExecMsg.getFloatValue(Tags.CumQty);
        avgPx = lastExecMsg.getFloatValue(Tags.AvgPx);
    }

Note: The FIXRegularOrder.getOrdStatus() is a more reliable way to retrieve the "real" order status. For example, if the order is currently partially filled and the application sent out an order cancel/replace. The "OrdStatus" from the execution message may be "Pending Replace". However, the FIXRegularOrder.getOrdStatus() will still be "PartiallyFilled".

This example works with FIX versions from 4.1 to 5.0+.