For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Support Center
OverviewAPIResources
OverviewAPIResources
  • REST API Endpoints
      • GETCommand Dependents
      • GETCommand Item
      • GETCommand Items
      • GETCommand L Dependents
      • GETCommand List
      • GETCommand Report Dependents
      • GETCommand Report Item
      • GETCommand Report Items
      • GETCommand Report L Dependents
      • GETCommand Report List
      • GETExecution Report Dependents
      • GETExecution Report Find
      • GETExecution Report Item
      • GETExecution Report Items
      • GETExecution Report L Dependents
      • GETExecution Report List
      • GETFill Dependents
      • GETFill Item
      • GETFill Items
      • GETFill L Dependents
      • GETFill List
      • GETFill Fee Dependents
      • GETFill Fee Item
      • GETFill Fee Items
      • GETFill Fee L Dependents
      • GETFill Fee List
      • POSTCancel Order
      • GETOrder Dependents
      • GETOrder Item
      • GETOrder Items
      • GETOrder L Dependents
      • POSTLiquidate Position
      • POSTLiquidate Positions
      • GETOrder List
      • POSTModify Order
      • POSTPlace OCO
      • POSTPlace Order
      • POSTPlace OSO
      • GETOrder Strategy Dependents
      • POSTInterrupt Order Strategy
      • GETOrder Strategy Item
      • GETOrder Strategy Items
      • GETOrder Strategy L Dependents
      • GETOrder Strategy List
      • POSTModify Order Strategy
      • POSTStart Order Strategy
      • GETOrder Strategy Link Dependents
      • GETOrder Strategy Link Item
      • GETOrder Strategy Link Items
      • GETOrder Strategy Link L Dependents
      • GETOrder Strategy Link List
      • GETOrder Version Dependents
      • GETOrder Version Item
      • GETOrder Version Items
      • GETOrder Version L Dependents
      • GETOrder Version List
Support Center
LogoLogo
REST API EndpointsOrders

Place OCO

POST
https://demo.tradovateapi.com/v1/order/placeoco
POST
/v1/order/placeoco
1const url = 'https://demo.tradovateapi.com/v1/order/placeoco';
2const options = {
3 method: 'POST',
4 headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
5 body: '{"action":"Buy","symbol":"string","orderQty":1,"orderType":"Limit","other":{"action":"Buy","orderType":"Limit"}}'
6};
7
8try {
9 const response = await fetch(url, options);
10 const data = await response.json();
11 console.log(data);
12} catch (error) {
13 console.error(error);
14}
200Successful
1{
2 "failureReason": "AccountClosed",
3 "failureText": "string",
4 "orderId": 1,
5 "ocoId": 1
6}
### 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 } ```
Was this page helpful?
Previous

Place Order

Next
Built with

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.

1const URL = 'demo.tradovateapi.com/v1'
2const limit = {
3 action: 'Sell',
4 orderType: 'Limit',
5 price: 4200.00
6}
7const oco = {
8 accountSpec: yourUserName,
9 accountId: yourAcctId,
10 action: "Buy",
11 symbol: "MESM1",
12 orderQty: 1,
13 orderType: "Stop",
14 price: 4100.00
15 isAutomated: true, //must be true if this isn't an order made directly by a human
16 other: limit
17}
18
19const response = await fetch(URL + '/order/placeoco', {
20 method: 'POST',
21 headers: {
22 'Accept': 'application/json',
23 'Authorization': `Bearer ${myAccessToken}`,
24 },
25 body: JSON.stringify(oco)
26})
27
28const 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:
expireTimedatetimeOptional
textstringOptional<=64 characters
activationTimedatetimeOptional
customTag50stringOptional<=64 characters
isAutomatedbooleanOptional

Response

PlaceOcoResult
failureReasonenum
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<=8192 characters
orderIdlong
ocoIdlong