Skip to main content

POST Flat Place Order

Close position and place order NT8

Unlike reverse positions, flat placing an order will close any existing position and continue on to place the order regardless of whether or not the position existed. This is useful to ensure you are always cleanly entering a new positions. The equivalent of a webhook signal with the flatten_first flag enabled.

Endpoint

POST /v1/api/accounts/{account}/orders/flatplace

Headers

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Path parameters

NameTypeRequiredDescription
accountstringRequiredName of account in NT8

Body parameters

NameTypeRequiredDescription
instrumentstringRequiredName of underlying instrument (e.g., "ES 12-25")
actionstringRequiredBUY, SELL
quantityintRequiredContract quantity of new order
orderTypestringRequiredMARKET, LIMIT, STOPMARKET, STOPLIMIT
timeInForcestringRequiredDAY, GTC
limitPricefloatOptionalLimit price when submitting limit order type
stopPricefloatOptionalStop price when submitting stop order type
ocoIdstringOptionalCreate or append to OCO order by ID
strategystringOptionalATM strategy name if opening with ATM template

Code examples

import requests

token = 'my-secret-token'

url = "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/flatplace"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
data = {
"instrument": "MES 12-25",
"action": "BUY",
"orderType": "MARKET",
"quantity": 1,
"timeInForce": "DAY"
# "limitPrice": 5500
# "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": "1ede9d7ad8124fd48e3177399bf90a04",
"success": true
}

Platform nuances

  • Flattening and order cancellation are limited to the requested instrument on the selected account.
  • If a position or working order exists, the add-on waits up to 4.5 seconds for the position to become flat and every order on that instrument to become terminal. If they do not clear, the request returns an error and does not place the new entry.
  • If the account is already flat with no working orders on the instrument, the request proceeds directly to placing the new order.

WebSocket API

This request can also be made over the WebSocket API. The account path parameter and request body fields are all passed inside args.

{
"action": "rpc",
"id": "my-request",
"api": "FlatPlace",
"args": {
"account": "Sim101",
"instrument": "ES 09-26",
"action": "Buy",
"orderType": "Market",
"quantity": 1,
"timeInForce": "Gtc"
}
}