class O2GLastOrderUpdateResponseReader
Brief
The class reads a response to a request for the current state of an order.
Details
To get information about the current state of an order, you must request it. The process of requesting the current order state consists of several steps that are described in the
Get Last Order Update section.
The possible states of different order types are described in the Orders State Machines section.
As an answer to the request, the trading server sends a response object of the GET_LAST_ORDER_UPDATE type.
This object is the response
parameter in your implementation of the
IO2GResponseListener.onRequestCompleted method.
To process the response contents you must use an instance of the O2GLastOrderUpdateResponseReader
class.
To create an instance of the O2GLastOrderUpdateResponseReader
class, pass the response object as an argument to the
O2GResponseReaderFactory.createLastOrderUpdateResponseReader method. For example,
O2GLastOrderUpdateResponseReader orderReader = factory.createLastOrderUpdateResponseReader(response);
Example
Requesting current order state by the order unique identifier [show]
Requesting current order state by the order unique identifier [hide]
public static void getLastOrderUpdate(O2GSession session, ResponseListener responseListener, String orderID, String accountName) {
O2GRequestFactory requestFactory = session.getRequestFactory();
if (requestFactory != null) {
O2GValueMap valuemap = requestFactory.createValueMap();
valuemap.setString(O2GRequestParamsEnum.COMMAND, Constants.Commands.GetLastOrderUpdate);
valuemap.setString(O2GRequestParamsEnum.ACCOUNT_NAME, accountName);
valuemap.setString(O2GRequestParamsEnum.KEY, Constants.KeyType.OrderID);
valuemap.setString(O2GRequestParamsEnum.ID, orderID);
O2GRequest request = requestFactory.createOrderRequest(valuemap);
responseListener.setRequest(request.getRequestId());
session.sendRequest(request);
Thread.sleep(1000);
}
}
// Set request in the implementation of IO2GResponseListener interface
public void setRequest(String requestID) {
mRequestID = requestID;
}
// Implementation of IO2GResponseListener interface public method onRequestCompleted
public void onRequestCompleted(String requestID, O2GResponse response) {
if (mRequestID.equals(requestID)) {
System.out.println("Request completed.\nrequestID= " + requestID);
O2GResponseReaderFactory readerFactory = mSession.getResponseReaderFactory();
if (readerFactory != null) {
if (response.getType() == O2GResponseType.GET_LAST_ORDER_UPDATE) {
O2GLastOrderUpdateResponseReader lastOrderUpdateResponseReader = readerFactory.createLastOrderUpdateResponseReader(response);
O2GOrderRow orderRow = lastOrderUpdateResponseReader.getOrder();
System.out.println("UpdateType: " + lastOrderUpdateResponseReader.getUpdateType().toString() +
" OrderID: " + orderRow.getOrderID() +
" Status: " + orderRow.getStatus());
}
}
}
}
The namespace is com.fxcore2
.
Public Methods |
getOrder
|
Gets an instance of the class that provides access to order information.
|
getUpdateType
|
Gets the last operation that has been performed with an order.
|
back