Skip to main content

GET All Positions

Get all positions NT8

Retrieve positions across all accounts in a single request.

Endpoint

GET /v1/api/positions

Headers

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Query parameters

NameTypeRequiredDescription
includeFlatbooleanOptionalInclude flat (zero-quantity) positions. Default: false

Code examples

import requests

token = 'my-secret-token'
url = "https://app.crosstrade.io/v1/api/positions"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}

try:
response = requests.get(url, headers=headers)
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")

Response

{
"positions": [
{
"type": "NinjaTrader.Cbi.Position",
"account": "Sim101",
"instrument": "MES 09-26",
"instrumentType": "Future",
"marketPosition": "Long",
"quantity": 7,
"averagePrice": 6615.178571428572,
"marketPrice": 6614.25,
"unrealizedProfitLoss": -32.50000000000455,
"tag": null
},
{
"type": "NinjaTrader.Cbi.Position",
"account": "Sim101",
"instrument": "NQ 09-26",
"instrumentType": "Future",
"marketPosition": "Short",
"quantity": 1,
"averagePrice": 24605.25,
"marketPrice": 24606.25,
"unrealizedProfitLoss": -20.0,
"tag": null
}
],
"count": 2,
"success": true
}

Platform nuances

By default, flat positions are excluded. Pass ?includeFlat=true to include them. The response returns the total number of rows in count alongside the positions collection.

WebSocket API

This request can also be made over the WebSocket API. Query parameters are passed inside args.

{
"action": "rpc",
"id": "my-request-id",
"api": "GetAllPositions",
"args": {
"includeFlat": false
}
}