Skip to main content

WEBSOCKET API Trading - Get closed positions

WEBSOCKET API Trading - Get closed positions

Written by Albert
Updated today

Get closed positions

Connection

URL:

/frontoffice/ws/v4/account?access_token={YOUR_ACCESS_TOKEN}

arguments array

The connection parameters.

In the first element, provide the accountId as a string.

invocationId string

The invocation identifier.

Must be unique and increase by 1 for each sent message.

target string

The stream name.

Specify "ClosePositionsOrders".

type int

The operation type.

Set to 4 to indicate a subscription to the stream.

Example:

{
"arguments": [
"67d0456f8c7b1108e4cf5d46"
],
"invocationId": "0",
"target": "ClosePositionsOrders",
"type": 4
}

Message

type string

The operation type.

2 indicates the streaming is in progress.

invocationId string

The invocation identifier. Same as in the request.

item array of objects

The array of position objects.

item.marketId string

The market identifier, in the following format: {marketType}.{baseAssetId}_{quoteAssetId}, for example: cfd.eth_eur.

item.marketType string

The market type.

Possible values:

  • Spot

  • Cfd

  • Perp

item.marketDisplayName string

The market ticker.

item.marketFullName string

The market full name or description (optional).

item.orderId string

The unique identifier of the order assigned by the system.

item.orderType string

The order type.

Possible values:

  • Market

  • Limit

item.timeInForce string

The time-in-force policy for the order, controlling its lifetime.

Possible values:

  • Gtc

  • Ioc

  • Fok

  • Gtd

  • Day

item.side string

The order side, indicating the direction of the trade.

Possible values:

  • Buy

  • Sell

item.positionCloseLotAmount decimal string

The closed volume, in lots, which is equivalent to the corresponding filled order volume.

item.reason string

The reason for position closing.

Possible values:

  • Trader

  • StopOut

  • MarketHalted

  • MarketDisabled

  • TakeProfit

  • StopLoss

  • Admin

item.realizedPnlInRAT decimal string

The actual profit or loss earned, in conversion to RAT.

For Long positions, this value is calculated as Position size Γ— (Close price – Open price).

For Short positions, this value is calculated as Position size Γ— (Open price – Close price).

item.closedAt dateTime

The timestamp when the position was closed, in ISO 8601 format.

item.positionId string

The unique identifier of the position assigned by the system.

item.openPrice decimal string

The volume-weighted average price (VWAP) at which the position was opened.

item.closePrice decimal string

The volume-weighted average price (VWAP) of trades related to a position-closing order.

item.positionPriceInRAT decimal string

The position price, in conversion to RAT.

item.rateToRAT decimal string

The conversion rate to RAT.

item.openedAt dateTime

The timestamp when the position was opened, in ISO 8601 format.

Example:

{
"type": 2,
"invocationId": "0",
"item": [
{
"marketId": "cfd.eur_chf",
"marketFullName": "",
"marketDisplayName": "EUR/CHF",
"marketType": "Cfd",
"orderId": "01JVSQ8WFA3QZ6AQTKYPXVXDWA",
"orderType": "Market",
"timeInForce": "Ioc",
"side": "Sell",
"positionCloseLotAmount": "0.01",
"reason": "Trader",
"realizedPnlInRAT": "-29.25",
"closedAt": "2025-05-21T15:26:57.0027785Z",
"positionId": "01JP4H3AMS7Q1H6Y6H3XJ52JTA",
"openPrice": "0.96304",
"closePrice": "0.93571",
"positionPriceInRAT": "1001.2",
"rateToRAT": "1.07",
"openedAt": "2025-03-12T06:36:31.257Z"
}
]
}

Did this answer your question?