Remove Orders from Existing Contingency Group
You can remove one or more orders from an existing contingency (OCO, OTO or ELS) group.
To remove orders from a contingency group:
1) Create an IO2GValueMap
and fill only one field:
Valuemap field |
Datatype |
Description |
Command |
const char * |
The command. Must be The field is obligatory. |
2) Create an IO2GValueMap
for each order you want to remove from the contingency group.
Fill these value maps as:
Valuemap field |
Datatype |
Description |
Command |
const char * |
The command. Must be The field is obligatory. |
AcctID |
const char * |
The identifier of the account which the order belongs to. The field is obligatory. |
OrderID |
const char * |
The identifier of the order to be removed from 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 IO2GValueMap.appendChild
method.
Please note that only dependent orders may be removed from OTO or ELS groups.
4) Pass the main valuemap
table to the createOrderRequest method.
Limitations:
1) All entry orders must be created for the same account.
Returns:
The createOrderRequest method will return an IO2GRequest (the main request) containing child requests. If 2 entry orders are removed, 2 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: Remove orders from an existing contingency group [hide]
void CExample::prepareParamsFromLoginRules(IO2GLoginRules *loginRules) { mParams = new OrderCreationParam(); O2G2Ptr<IO2GResponseReaderFactory> factory = mSession->getResponseReaderFactory(); // Get first account from login O2G2Ptr<IO2GResponse> accountsResponse = loginRules->getTableRefreshResponse(Accounts); O2G2Ptr<IO2GAccountsTableResponseReader> accountsReader = factory->createAccountsTableReader(accountsResponse); O2G2Ptr<IO2GAccountRow> account = accountsReader->getRow(0); // Store account id mParams->mAccountID = account->getAccountID(); // Store base amount mParams->mBaseAmount = account->getBaseUnitSize(); // Get offers for eur/usd O2G2Ptr<IO2GResponse> offerResponse = loginRules->getTableRefreshResponse(Offers); O2G2Ptr<IO2GOffersTableResponseReader> offersReader = factory->createOffersTableReader(offerResponse); for (int i = 0; i < offersReader->size(); i++) { O2G2Ptr<IO2GOfferRow> offer = offersReader->getRow(i); if (_stricmp(offer->getInstrument(), "EUR/USD") == 0) { mParams->mOfferID = offer->getOfferID(); mParams->mAsk = offer->getAsk(); mParams->mBid = offer->getBid(); mParams->mPointSize = offer->getPointSize(); break; } } } // Helper method for creating valueMap for existing order IO2GValueMap* CExample::existOrder(const char* orderID, const char* accountID) { using namespace O2G2; O2G2Ptr<IO2GRequestFactory> factory = getRequestFactory(); IO2GValueMap* valuemap = factory->createValueMap(); valuemap->setString(OrderID, orderID); valuemap->setString(AccountID, accountID); return valuemap; } void CreateOrderSample::removeFromGroup(const char* accountID, const char* secID1, const char* secID2) { using namespace O2G2; O2G2Ptr<IO2GRequestFactory> factory = mSession->getRequestFactory(); // create JoinToExistingContingencyGroup command // this command cannot be created as tree O2G2Ptr<IO2GValueMap> valuemap = factory->createValueMap(); valuemap->setString(Command, Commands::RemoveFromContingencyGroup); // secondary order IO2GValueMap* valuemapRemove = existOrder(secID1, accountID); valuemapRemove->setString(Command, Commands::RemoveFromContingencyGroup); valuemap->appendChild(valuemapRemove); // secondary order valuemapRemove = existOrder(secID2, accountID); valuemapRemove->setString(Command, Commands::RemoveFromContingencyGroup); valuemap->appendChild(valuemapRemove); // create request from valueMap O2G2Ptr<IO2GRequest> request = factory->createOrderRequest(valuemap); for (int i = 0; i < request->getChildrenCount(); i++) { O2G2Ptr<IO2GRequest> childRequest = request->getChildRequest(i); mActions[childRequest->getRequestID()] = manageOTOAction; } mSession->sendRequest(request); }