- Solve real problems with our hands-on interface
- Progress from basic puts and calls to advanced strategies
Posted September 3, 2021 at 1:11 pm
One-Cancels All (OCA) order type allows an investor to place multiple and possibly unrelated orders assigned to a group. It’s designed to allow investors to submit several orders aimed at taking advantage of the most desirable price within the group. Completion of one piece of the group causes cancellation of the remaining group orders while partial completion causes the group to rebalance.
The endpoint /iserver/account/{accounted}/orders can be used to pass order request info in an Array by setting isSingleGroup to true in each order. All orders in the same group will be assigned the same oca_group_id. After the orders are successfully placed, send the endpoint /iserver/account/order/status/{orderId} to receive the oca_group_id.
Please be sure to authenticate first in order to resolve the below URLs.
For authentication details, visit https://interactivebrokers.github.io/cpwebapi/index.html#login
POST
https://localhost:5000/v1/api/iserver/account/{accountId}/orders
Request Body:
Array () [
Response:
Array () [
]
Please be sure to authenticate first in order to resolve the below URLs.
For authentication details, visit https://interactivebrokers.github.io/cpwebapi/index.html#login
Submit two orders within the same /orders endpoint including isSingleGroup: true for both orders.
Request:
POST
https://localhost:5000/v1/api/iserver/account/DU***14/orders
Request Body:
{
“orders”: [
{
“acctId”: “DU***14”,
“conid”: “265598”,
“secType”: “265598:STK”,
“cOID”: “66827301”,
“orderType”: “LMT”,
“listingExchange”: “SMART”,
“outsideRTH”: true,
“price”: 145.25,
“side”: “BUY”,
“ticker”: “AAPL”,
“tif”: “DAY”,
“referrer”: “testOCA”,
“quantity”: 1,
“useAdaptive”: false,
“isClose”: false
“isSingleGroup”: true
},
{
“acctId”: “DU***14”,
“conid”: “8314”,
“secType”: “8314:STK”,
“cOID”: “66827302”,
“orderType”: “LMT”,
“listingExchange”: “SMART”,
“outsideRTH”: true,
“price”: 125.5,
“side”: “BUY”,
“ticker”: “IBML”,
“tif”: “DAY”,
“referrer”: “testOCA”,
“quantity”: 1,
“useAdaptive”: false,
“isClose”: false,
“isSingleGroup”: “true”,
}
]
}
Response:
[
{
“order_id”: “1297028126”,
“order_status”: “PreSubmitted”,
“local_order_id”: “66827302”
},
{
“order_id”: “1297028125”,
“order_status”: “Submitted”,
“parent_order_id”: “66827301”
“encrypt_message":"1”
}
]
Once orders are successfully transmitted, you will return a unique order_id for each order in the Group. Send a separate /status endpoint for each order_id to identify the oca_group_id.
Request:
POST
https://localhost:5000/v1/api/iserver/account/order/status/1297028125
Response:
{
"sub_type": null,
"request_id": "193136",
"order_id": 1297028125,
"conidex": "265598",
"conid": 265598,
"symbol": "AAPL",
"side": "B",
"contract_description_1": "AAPL",
"listing_exchange": "NASDAQ.NMS",
"option_acct": "c",
"company_name": "APPLE INC",
"size": "1.0",
"total_size": "1.0",
"currency": "USD",
"account": "DU***14",
"order_type": "LIMIT",
"limit_price": "145.25",
"cum_fill": "0.0",
"order_status": "Submitted",
"order_status_description": "Order Submitted",
"tif": "DAY",
"fg_color": "#000000",
"bg_color": "#00F000",
"order_not_editable": false,
"editable_fields": "\u001e",
"cannot_cancel_order": false,
"outside_rth": true,
"deactivate_order": false,
"use_price_mgmt_algo": true,
"sec_type": "STK",
"available_chart_periods": "#R|1",
"order_description": "Buy 1 Limit 145.25 DAY",
"order_description_with_contract": "Buy 1 AAPL Limit 145.25 DAY",
"alert_active": 1,
"child_order_type": "3",
"size_and_fills": "0/1",
"oca_group_id": "oco-1297028125",
"exit_strategy_display_price": "145.25",
"exit_strategy_chart_description": "Buy 1 Limit 145.25 DAY",
"exit_strategy_tool_availability": "1",
"allowed_duplicate_opposite": true,
"order_time": "210901211533"
}
Request:
POST
https://localhost:5000/v1/api/iserver/account/order/status/1297028126
Response:
{
"sub_type": null,
"request_id": "193367",
"order_id": 1297028126,
"conidex": "8314",
"conid": 8314,
"symbol": "IBM",
"side": "B",
"contract_description_1": "IBM",
"listing_exchange": "NYSE",
"option_acct": "c",
"company_name": "INTL BUSINESS MACHINES CORP",
"size": "1.0",
"total_size": "1.0",
"currency": "USD",
"account": "DU***14",
"order_type": "LIMIT",
"limit_price": "125.50",
"cum_fill": "0.0",
"order_status": "PreSubmitted",
"order_status_description": "Order Submitted",
"tif": "DAY",
"fg_color": "#FFFFFF",
"bg_color": "#0000CC",
"order_not_editable": false,
"editable_fields": "\u001e",
"cannot_cancel_order": false,
"outside_rth": false,
"deactivate_order": false,
"use_price_mgmt_algo": true,
"sec_type": "STK",
"available_chart_periods": "#R|1",
"order_description": "Buy 1 Limit 125.50 DAY",
"order_description_with_contract": "Buy 1 IBM Limit 125.50 DAY",
"alert_active": 1,
"child_order_type": "3",
"size_and_fills": "0/1",
"oca_group_id": "oco-1297028125",
"exit_strategy_display_price": "125.50",
"exit_strategy_chart_description": "Buy 1 Limit 125.50 DAY",
"exit_strategy_tool_availability": "1",
"allowed_duplicate_opposite": true,
"order_time": "210901211533"
}
If you have any further questions or issues creating OCA orders, please reach out to the API Group, ref: https://www.interactivebrokers.com/en/index.php?f=47047.
Visit the IBKR API Center for Downloads, Resources, and Technical Details:
https://www.interactivebrokers.com/en/trading/ib-api.php.
Any stock, options or futures symbols displayed are for illustrative purposes only and are not intended to portray recommendations.
The analysis in this material is provided for information only and is not and should not be construed as an offer to sell or the solicitation of an offer to buy any security. To the extent that this material discusses general market activity, industry or sector trends or other broad-based economic or political conditions, it should not be construed as research or investment advice. To the extent that it includes references to specific securities, commodities, currencies, or other instruments, those references do not constitute a recommendation by IBKR to buy, sell or hold such investments. This material does not and is not intended to take into account the particular financial conditions, investment objectives or requirements of individual customers. Before acting on this material, you should consider whether it is suitable for your particular circumstances and, as necessary, seek professional advice.
The views and opinions expressed herein are those of the author and do not necessarily reflect the views of Interactive Brokers, its affiliates, or its employees.
The order types available through Interactive Brokers LLC's Trader Workstation are designed to help you limit your loss and/or lock in a profit. Market conditions and other factors may affect execution. In general, orders guarantee a fill or guarantee a price, but not both. In extreme market conditions, an order may either be executed at a different price than anticipated or may not be filled in the marketplace.
Join The Conversation
For specific platform feedback and suggestions, please submit it directly to our team using these instructions.
If you have an account-specific question or concern, please reach out to Client Services.
We encourage you to look through our FAQs before posting. Your question may already be covered!