Place OCO

### Place a Order Cancels Order order strategy. OCO order strategies link 2 orders together such that if one order is filled, the other order is cancelled. You must provide an `other` parameter pertaining to the order linked to this one. The `other` must specify an `action` and an `orderType` which determines the other parameters that must be set. For example a Limit or Stop order must use the `price` parameter, but a Stop-Limit will require a `price` and a `stopPrice`. Below is an example of an OCO that either sells to take profit at 4200 points, or sells to stop loss at 4100 points. ```js const URL = 'demo.tradovateapi.com/v1' const limit = { action: 'Sell', orderType: 'Limit', price: 4200.00 } const oco = { accountSpec: yourUserName, accountId: yourAcctId, action: "Buy", symbol: "MESM1", orderQty: 1, orderType: "Stop", price: 4100.00 isAutomated: true, //must be true if this isn't an order made directly by a human other: limit } const response = await fetch(URL + '/order/placeoco', { method: 'POST', headers: { 'Accept': 'application/json', 'Authorization': `Bearer ${myAccessToken}`, }, body: JSON.stringify(oco) }) const json = await response.json() // { orderId: 0000000, ocoId: 0000000 } ```

Authentication

AuthorizationBearer

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

Request

This endpoint expects an object.
actionenumRequired
Buy, Sell
Allowed values:
symbolstringRequired<=64 characters
orderQtyintegerRequired>=0
orderTypeenumRequired
Limit, MIT, Market, QTS, Stop, StopLimit, TrailingStop, TrailingStopLimit
otherobjectRequired
accountSpecstringOptional<=64 characters
accountIdlongOptional
clOrdIdstringOptional<=64 characters
pricedoubleOptional
stopPricedoubleOptional
maxShowintegerOptional>=0
pegDifferencedoubleOptional
timeInForceenumOptional
Day, FOK, GTC, GTD, IOC
Allowed values:
expireTimestringOptionalformat: "date-time"
textstringOptional<=64 characters
activationTimestringOptionalformat: "date-time"
customTag50stringOptional<=64 characters
isAutomatedbooleanOptional

Response

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