Place OCO

View as Markdown
### Place an OCO (one-cancels-the-other) order strategy. **Available to:** All authenticated users **Environments:** Demo, Live **[Rate Limit](/api/authentication#request-rate-limits-and-time-penalties):** 1,500 requests per hour, 1-second back-off, counts all requests An OCO strategy links two orders so that when one fills, the other is automatically cancelled — commonly used to pair a take-profit with a stop-loss. Provide the primary order's fields (account, `action`, `symbol`, `orderQty`, `orderType`, and the price fields its type requires), plus an `other` object describing the linked order. The `other` order's own `action` and `orderType` determine which price fields it needs. On success, the response includes both an `orderId` and an `ocoId`. ```js // Demo environment; for Live use https://live.tradovateapi.com/v1 const URL = 'https://demo.tradovateapi.com/v1' const oco = { accountSpec: yourUserName, accountId: yourAccountId, action: "Sell", symbol: "MESM1", orderType: "Limit", price: 4200.00, orderQty: 1, isAutomated: true, other: { action: "Sell", orderType: "Stop", stopPrice: 4100.00 } } const result = await fetch(`${URL}/order/placeoco`, { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Bearer ${myAccessToken}` }, body: JSON.stringify(oco) }).then(res => res.json()) // { orderId, ocoId } on success ``` <Warning> Set `isAutomated` to `true` for any order placed by code or an automated process, and `false` only for an order a human places directly. Misreporting this can violate exchange policies. </Warning> As with any order, acceptance is subject to market, exchange, and risk-management rules. When rejected, the response carries a `failureReason` and `failureText`. **Common Failure Scenarios** - A risk limit blocks the order (for example, `MaxPosLimitReached`). - A contract or price is invalid (`InvalidContract`, `InvalidPrice`). - The trading session is closed (`SessionClosed`). **Error Messages** | `failureReason` | Trigger | |-----------------|---------| | `InvalidPrice` | A price is missing or invalid for one of the linked orders' types. | | `MaxPosLimitReached` | The order would exceed the account's position limit. | | `SessionClosed` | The trading session is closed. | See the `failureReason` enum in the response schema for the complete list of values.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
actionenumRequired
Buy, Sell
symbolstringRequired<=64 characters
orderQtyintegerRequired
orderTypeenumRequired
Limit, LimitIfTouched, MIT, Market, MarketLimit, MarketStopWithProtection, MarketWithProtection, QTS, Stop, StopLimit, TrailingStop, TrailingStopLimit
otherobjectRequired
accountSpecstringOptional<=64 characters
accountIdlongOptional
clOrdIdstringOptional<=64 characters
pricedoubleOptional
stopPricedoubleOptional
limitIfTouchedPricedoubleOptional
maxShowintegerOptional
pegDifferencedoubleOptional
timeInForceenumOptional
Day, FOK, GTC, GTD, IOC
expireTimedatetimeOptional
textstringOptional<=64 characters
activationTimedatetimeOptional
customTag50stringOptional<=64 characters
isAutomatedbooleanOptional

Response

PlaceOcoResult
failureReasonenum
AccountClosed, AdvancedTrailingStopUnsupported, AnotherCommandPending, BackMonthProhibited, ExecutionProviderNotConfigured, ExecutionProviderUnavailable, InvalidContract, InvalidPrice, KeyInformationDocumentRequired, LiquidationOnly, LiquidationOnlyBeforeExpiration, MaxOrderQtyIsNotSpecified, MaxOrderQtyLimitReached, MaxPosLimitMisconfigured, MaxPosLimitReached, MaxTotalPosLimitReached, MultipleAccountPlanRequired, NoQuote, NotEnoughLiquidity, OtherExecutionRelated, ParentRejected, RiskCheckTimeout, SSFNFAComplianceRequired, SSFNFAComplianceRequiredJointOnly, SSFRiskDisclosureAcknowledgmentRequired, SessionClosed, Success, TooLate, TradingLocked, TrailingStopNonOrderQtyModify, Unauthorized, UnknownReason, Unsupported
failureTextstring<=8192 characters
orderIdlong
ocoIdlong