Skip to main content

POST Place Order

Place an order

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

Headers

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Path Parameters

NameTypeRequiredDescription
accountstringRequiredName of account in NT8

Body

NameTypeRequiredDescription
instrumentstringRequiredName of underlying instrument (e.g., "ES 12-25")
actionstringRequiredBUY, SELL
quantityintegerRequiredContract 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
orderIdstringOptionalCustom order ID to assign at placement. If provided, this ID can be used to look up or cancel the order later.
requireMarketPositionstringOptionalComma-separated list of position states that must be true for the order to be accepted: "flat", "long", "short". Example: "flat" blocks the order if a position is already open. "flat,long" allows entry from flat or adding to a long. If the condition is not met, a 400 error is returned and no order is placed.
maxPositionsintegerOptionalBlocks the order if the account already has this many or more open positions across all instruments. Only applies when opening a new position, not adding to an existing one.

Code Examples

import requests

token = 'my-secret-token'

url = "https://app.crosstrade.io/v1/api/accounts/Sim101/orders/place"
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": "cb1fc8d4e1a84d29ae38fea964aaac8c",
"success": true
}

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": "PlaceOrder",
"args": {
"account": "Sim101",
"instrument": "ES 09-26",
"action": "Buy",
"orderType": "Market",
"quantity": 1,
"timeInForce": "Gtc"
}
}