GET Position
Get a specific position by instrument
GET /v1/api/accounts/{account}/position
Headers
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Path Parameters
| Name | Type | Required | Description |
|---|---|---|---|
account | string | Required | Name of account in NT8 |
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
instrument | string | Required | URL-encoded instrument name |
Code Examples
- Python
import requests
token = 'my-secret-token'
url = "https://app.crosstrade.io/v1/api/accounts/Sim101/position"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
try:
response = requests.get(url, headers=headers, params={'instrument': 'MES 06-25'})
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")
Response
- 200
- 400
{
"type": "NinjaTrader.Cbi.Position",
"account": "Sim101",
"instrument": "ES 12-25",
"instrumentType": "Future",
"marketPosition": "Long",
"quantity": 4,
"averagePrice": 5779.8125,
"marketPrice": 5789.5,
"unrealizedProfitLoss": 1937.5,
"success": true
}
{
"error": "Invalid request"
}
WebSocket API
This request can also be made over the WebSocket API. The account path parameter and instrument query parameter are passed inside args.
{
"action": "rpc",
"id": "my-request-id",
"api": "GetPosition",
"args": {
"account": "Sim101",
"instrument": "ES 09-26"
}
}