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.
action
Buy, Sell
Allowed values:
symbol
orderQty
orderType
Limit, MIT, Market, QTS, Stop, StopLimit, TrailingStop, TrailingStopLimit
other
accountSpec
accountId
clOrdId
price
stopPrice
maxShow
pegDifference
timeInForce
Day, FOK, GTC, GTD, IOC
Allowed values:
expireTime
text
activationTime
customTag50
isAutomated
Response
PlaceOcoResult
failureReason
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
failureText
orderId
ocoId

