Skip to main content

POST Replace Order

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

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Path parameters

NameTypeRequiredDescription
accountstringRequiredName of account in NT8
orderIdstringRequiredID of the order to by replaced

Body parameters

NameTypeRequiredDescription
instrumentstringOptionalReplacement instrument. Defaults to the existing order's instrument and cannot move the order to a different instrument.
actionstringOptionalBUY or SELL. Defaults to the existing order action.
quantityintOptionalReplacement contract quantity. Defaults to the existing order quantity.
orderTypestringOptionalMARKET, LIMIT, STOPMARKET, or STOPLIMIT. Defaults to the existing order type.
timeInForcestringOptionalDAY or GTC. Defaults to the existing order time in force.
limitPricefloatOptionalReplacement limit price. Defaults to the existing limit price when required by its order type.
stopPricefloatOptionalReplacement stop price. Defaults to the existing stop price when required by its order type.
ocoIdstringOptionalCreate or append to OCO order by ID.
strategystringOptionalATM strategy name if opening with an ATM template.

Code examples

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}")

Response

{
"orderId": "36f59a2f4594436084484b92350ca25a",
"success": true
}

Platform nuances

  • Only account and orderId are 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 Cancelled state.

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"
}
}