POST Replace Order
Cancel & replace an existing order by ID
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 |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
orderId | string | Required | ID of the order to by replaced |
Body
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Required | Name of underlying instrument (e.g., "ES 12-25") |
action | string | Required | BUY, SELL |
quantity | integer | Required | Contract quantity of new order |
orderType | string | Required | MARKET, LIMIT, STOPMARKET, STOPLIMIT |
timeInForce | string | Required | DAY, GTC |
limitPrice | float | Optional | Limit price when submitting limit order type |
stopPrice | float | Optional | Stop price when submitting stop order type |
ocoId | string | Optional | Create or append to OCO order by ID |
strategy | string | Optional | ATM strategy name if opening with ATM template |
Code Examples
- Python
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
- 200
- 400
{
"orderId": "36f59a2f4594436084484b92350ca25a",
"success": true
}
{
"error": "Invalid request"
}
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"
}
}