Create New Contingency Group

You can join two or more existing entry orders into a new contingency (OCO, OTO or ELS) group.

To join orders into a contingency group:

1) Create an O2GValueMap and fill only two fields:

Valuemap field

Datatype

Description

COMMAND

String

The command. Must be JoinToNewContingencyGroup.

The field is obligatory.

CONTINGENCY_GROUP_TYPE

int

The type of a new contingency group. Must be:

1

OCO group.

2

OTO group.

3

ELS group.

The field is obligatory.

2) Create an O2GValueMap for each entry order you want to add into the contingency group. Fill these value maps as:

Valuemap field

Datatype

Description

ACCOUNT_ID

String

The identifier of the account which the order belongs to.

The field is obligatory.

ORDER_ID

String

The identifier of the order to be included into the group.

The order must exist, must be an entry order (LE or SE) and must be in the Waiting status.

The field is obligatory.

3) Append each entry order valuemap to the main valuemap using the O2GValueMap.appendChild method.

For OTO and ELS groups, append the order that must be a root order of the contingency group first.

4) Pass the main valuemap table to the createOrderRequest method.

Limitations:

All entry orders must be created for the same account.

Returns:

The createOrderRequest method will return an O2GRequest (the main request) containing child requests. If 3 entry orders are created, 3 child requests will be returned. Note that you will receive responses to the child requests and will not receive a response to the main request.

Example: Create an new contingency group [hide]

   public void joinNewContingencyGroup(String sAccountID, int iContingencyType, String sPrimaryID, String sSecondaryID1, String sSecondaryID2)
   {
        O2GRequestFactory factory = mSession.getRequestFactory();
        if (factory == null) {
            return;
        }
        O2GValueMap valuemap = factory.createValueMap();
        valuemap.setString(O2GRequestParamsEnum.COMMAND, Constants.Commands.JoinToNewContingencyGroup);
        //set contingencyType for created group
        valuemap.setInt(O2GRequestParamsEnum.CONTINGENCY_GROUP_TYPE, iContingencyType);
 
        // primary order
        valuemap.appendChild(createValueMapForExistingOrder(sPrimaryID, sAccountID));
        // secondary order
        valuemap.appendChild(createValueMapForExistingOrder(sSecondaryID1, sAccountID));
        // secondary order
        valuemap.appendChild(createValueMapForExistingOrder(sSecondaryID2, sAccountID));
 
        // create request from valueMap
        O2GRequest request = factory.createOrderRequest(valuemap);
        mSession.sendRequest(request);
    }
 
    public O2GValueMap createValueMapForExistingOrder(String sOrderID, String sAccountID)
    {
      O2GRequestFactory factory = mSession.getRequestFactory();
      O2GValueMap valuemap = factory.createValueMap();
      valuemap.setString(O2GRequestParamsEnum.ORDER_ID, sOrderID);
      valuemap.setString(O2GRequestParamsEnum.ACCOUNT_ID, sAccountID);
      return valuemap;
    }

back