Skip to main content

GET All Positions

Retrieve positions across all accounts in a single request. By default, flat positions are excluded. Pass ?includeFlat=true to include them.

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 03-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 06-26",
"instrumentType": "Future",
"marketPosition": "Short",
"quantity": 1,
"averagePrice": 24605.25,
"marketPrice": 24606.25,
"unrealizedProfitLoss": -20.0,
"tag": null
},
],
"count": 2,
"success": true
}

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
}
}