Skip to main content

POST Reverse Position

Combined Close Position and Place Order NT8

Closes the current position and opens a new one with the parameters you specify. Requires action, quantity, orderType, and timeInForce. Returns an error if no position is currently open. Use this when you need explicit control over the size or order type of the replacement entry.

Endpoint

POST /v1/api/accounts/{account}/positions/reverseposition

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-24")
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/positions/reverseposition"
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
}

Platform nuances

info

Flatten-wait behavior — Before placing the new entry order, this endpoint waits for the existing position to fully close and all associated orders to clear (up to ~5 seconds). This prevents the double-position problem that occurs when an entry fills before the close has processed. Under normal live conditions this wait is near-instant. In sim or during high broker latency, the full wait may be observed. If settlement times out, the operation fails closed and does not place the replacement entry.

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