POST Replace Order
- NT8
- Tradovate
Cancel & replace an existing order by ID NT8
Cancels one working order and submits its replacement as a single API workflow.
Endpoint
POST /v1/api/accounts/{account}/orders/{orderId}/replace
Headers
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
account | string | Required | Name of account in NT8 |
orderId | string | Required | ID of the order to by replaced |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Optional | Replacement instrument. Defaults to the existing order's instrument and cannot move the order to a different instrument. |
action | string | Optional | BUY or SELL. Defaults to the existing order action. |
quantity | int | Optional | Replacement contract quantity. Defaults to the existing order quantity. |
orderType | string | Optional | MARKET, LIMIT, STOPMARKET, or STOPLIMIT. Defaults to the existing order type. |
timeInForce | string | Optional | DAY or GTC. Defaults to the existing order time in force. |
limitPrice | float | Optional | Replacement limit price. Defaults to the existing limit price when required by its order type. |
stopPrice | float | Optional | Replacement stop price. Defaults to the existing stop price when required by its order type. |
ocoId | string | Optional | Create or append to OCO order by ID. |
strategy | string | Optional | ATM strategy name if opening with an ATM template. |
Code examples
- Python
- JavaScript
- cURL
import requests
token = 'my-secret-token'
url = "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/fba1e883dbd241308814d2d1f5687ace/replace"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
data = {
"instrument": "MES 12-25",
"action": "BUY",
"orderType": "LIMIT",
"quantity": 1,
"timeInForce": "DAY",
"limitPrice": 6000
# "stopPrice": 0,
# "ocoId": "abc123",
# "strategy": "MyAtmStrategy"
}
try:
response = requests.post(url, headers=headers, json=data)
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")
const token = 'my-secret-token';
const url = "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/fba1e883dbd241308814d2d1f5687ace/replace";
const data = {
instrument: "MES 12-25",
action: "BUY",
orderType: "LIMIT",
quantity: 1,
timeInForce: "DAY",
limitPrice: 6000
// stopPrice: 0,
// ocoId: "abc123",
// strategy: "MyAtmStrategy"
};
fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
TOKEN="my-secret-token"
curl -X POST "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/fba1e883dbd241308814d2d1f5687ace/replace" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"instrument": "MES 12-25",
"action": "BUY",
"orderType": "LIMIT",
"quantity": 1,
"timeInForce": "DAY",
"limitPrice": 6000
}'
Response
- 200
- 400
{
"orderId": "36f59a2f4594436084484b92350ca25a",
"success": true
}
{
"error": "Invalid request"
}
Platform nuances
- Only
accountandorderIdare required. Omitted instrument, action, order type, quantity, time in force, and applicable price fields are restored from the existing order. - A replacement cannot move the order to another instrument.
- The add-on waits up to 4.5 seconds for the original order and mapped Trade Copier follower orders to finish cancelling. The replacement is placed only when those orders finish in the
Cancelledstate.
WebSocket API
This request can also be made over the WebSocket API. The account and orderId path parameters and request body fields are all passed inside args.
{
"action": "rpc",
"id": "my-request-id",
"api": "CancelReplace",
"args": {
"account": "Sim101",
"orderId": "492281fc515e431692da57d957cfebb6",
"instrument": "ES 09-26",
"action": "Buy",
"orderType": "Limit",
"quantity": 2,
"limitPrice": 5400.00,
"timeInForce": "Gtc"
}
}
Cancel & replace an existing order by ID Tradovate
Cancels one working Tradovate order and submits its replacement as one durable, owner-fenced workflow. No NinjaTrader add-on is involved: the command runs server-side with the same validation, Account Manager locks, and Trade Copier fan-out as a webhook signal.
Endpoint
POST /v1/api/tv/accounts/{account}/orders/{id}/replace
Headers
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
account | string | Required | Tradovate account name, for example DEMO12345678. |
id | string | Required | Tradovate order id or an orderId assigned on an earlier place call. |
Body parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Required | Continuous (ES1!), NT8 (ES 09-26), or Tradovate (ESU6) instrument form. |
action | string | Required | buy or sell for the replacement. |
qty | int | Required | Replacement contract quantity. |
orderType | string | Required | Replacement order type. |
limitPrice | number | Optional | Replacement limit price. |
stopPrice | number | Optional | Replacement stop price. |
tif | string | Optional | Replacement time in force. |
text | string | Optional | Free-form replacement order note. Truncated to 64 characters (Tradovate's limit). |
expireTime | string | Optional | ISO-8601 expiry; required when tif=gtd. |
maxShow | int | Optional | Native iceberg display quantity. |
trailOffset | number | Optional | Native trailing-stop distance. Required for trailing order types. |
pegDifference | number | Optional | Alias of trailOffset. |
requireMarketPosition | string | Optional | Gate the operation on flat, long, or short. |
maxPositions | int | Optional | Block the replacement when this many positions are already open. |
cancelAfter | int | Optional | Cancel an unfilled replacement limit order after 1 to 180 minutes. |
syncStrategy | bool | Optional | Enable Tradovate Strategy Sync for this entry command. |
marketPosition | string | Optional | Remote strategy target side: flat, long, or short. |
prevMarketPosition | string | Optional | Remote strategy side before this signal. |
outOfSync | string | Optional | Mismatch policy: wait, flatten, ignore, or resync. |
targetQuantity | int | Optional | Exact signed target quantity for resync mode. |
strategyExitBlock | bool | Optional | Reject non-opening strategy transitions. |
Code examples
- Python
- JavaScript
- cURL
import requests
token = 'my-secret-token'
url = "https://app.crosstrade.io/v1/api/tv/accounts/DEMO12345678/orders/123456789/replace"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
data = {
"instrument": "ES1!",
"action": "buy",
"qty": 1,
"orderType": "limit",
"limitPrice": 5400.00
}
try:
response = requests.post(url, headers=headers, json=data)
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")
const token = 'my-secret-token';
const url = "https://app.crosstrade.io/v1/api/tv/accounts/DEMO12345678/orders/123456789/replace";
const data = {
instrument: "ES1!",
action: "buy",
qty: 1,
orderType: "limit",
limitPrice: 5400.00
};
fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify(data)
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
TOKEN="my-secret-token"
curl -X POST "https://app.crosstrade.io/v1/api/tv/accounts/DEMO12345678/orders/123456789/replace" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"instrument": "ES1!", "action": "buy", "qty": 1, "orderType": "limit", "limitPrice": 5400.00}'
Response
The response is the response envelope with api set to cancel_replace.
{
"success": true,
"destination": "tradovate",
"api": "cancel_replace",
"account": "DEMO12345678",
"instrument": "ES1!",
"response": {},
"durationMs": 214
}
Platform nuances
- Tradovate uses
{id}in the path where NT8 uses{orderId}. The body fields use the same camelCase keys as the NT8 surface. - Concurrent operations on the same original order are serialized, and staged recovery state is persisted before each broker mutation.
- The original order must belong to the
{account}in the path, and the replacement instrument must resolve to the same exact contract. - CrossTrade confirms the leader cancellation and every mapped Trade Copier follower cancellation before replacement fan-out.
- If a cancel or placement result is ambiguous, CrossTrade does not resend it. It returns
reconciliation_required; reconcile broker orders before starting another replacement. - Account Manager locks apply. On failure, the response is
{"success": false, "error": "<message>"}.
See the Tradovate API overview for the full field grammar, mutation safety guarantees, and error table.