Skip to content

Get Position History (WebSocket)

Retrieve closed position history for an authenticated subaccount over WebSocket with symbol, time-range, and pagination filters.

Endpoint

ws.send() wss://api.synthetix.io/v1/ws/trade

Request

Request Format

{
  "id": "get-position-history-1",
  "method": "post",
  "params": {
    "action": "getPositionHistory",
    "subaccountId": "123456789",
    "symbol": "BTC-USDT",
    "fromTime": 1769364177000,
    "toTime": 1769450577000,
    "limit": 50,
    "offset": 0,
    "signature": {
      "v": 27,
      "r": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
      "s": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"
    }
  }
}

Parameters

Request Parameters

ParameterTypeRequiredDescription
idstringYesClient-generated request identifier
methodstringYesMust be "post"
paramsobjectYesRequest payload container

Params Object

ParameterTypeRequiredDescription
actionstringYesMust be "getPositionHistory"
subaccountIdstringYesSubaccount ID in request payload. The authenticated selected account is enforced server-side for access control
symbolstringNoFilter by symbol (for example "BTC-USDT")
fromTimeintegerNoStart timestamp in milliseconds (inclusive)
toTimeintegerNoEnd timestamp in milliseconds (inclusive)
limitintegerNoNumber of records to return (default: 100)
offsetintegerNoNumber of records to skip (default: 0)
signatureobjectYesEIP-712 signature for the request

This read endpoint does not require nonce management in its request flow.

Response Format

Success Response

{
  "id": "get-position-history-1",
  "status": 200,
  "result": {
    "status": "ok",
    "response": {
      "positions": [
        {
          "positionId": "2015847946616049664",
          "symbol": "BTC-USDT",
          "side": "long",
          "entryPrice": "95000",
          "quantity": "0.001",
          "closePrice": "96000",
          "closeReason": "close",
          "realizedPnl": "1",
          "accumulatedFees": "0.1",
          "netFunding": "0",
          "closedAt": 1769450577774,
          "createdAt": 1769450577000,
          "tradeId": "123"
        }
      ],
      "hasMore": false
    },
    "requestId": "abcd1234",
    "request_id": "abcd1234",
    "timestamp": 1769450577774
  }
}

Error Response

{
  "id": "get-position-history-1",
  "status": 400,
  "result": null,
  "error": {
    "code": "VALIDATION_ERROR",
    "category": "REQUEST",
    "message": "Invalid time range",
    "retryable": false
  }
}

Position History Object

FieldTypeDescription
positionIdstringUnique position identifier
symbolstringTrading pair symbol
sidestringPosition side ("long" or "short")
entryPricestringAverage entry price
quantitystringPosition size
closePricestringExecution price of closure
closeReasonstringPosition close reason
realizedPnlstringRealized PnL
accumulatedFeesstringTotal fees for the position
netFundingstringNet funding paid/received
closedAtintegerPosition close timestamp in milliseconds
createdAtintegerPosition creation timestamp in milliseconds
tradeIdstringAssociated trade identifier

Error Handling

Error CodeDescriptionRetryable
UNAUTHORIZEDEIP-712 signature validation failedNo
VALIDATION_ERRORRequest validation failedNo
MISSING_REQUIRED_FIELDRequired field is missingNo
INVALID_FORMATField format is invalidNo
INVALID_VALUEInvalid parameter valueNo
RATE_LIMIT_EXCEEDEDToo many requests in time windowYes
INSUFFICIENT_MARGINNot enough margin for tradeNo
ORDER_NOT_FOUNDOrder does not existNo
OPERATION_TIMEOUTOperation timed outYes
ErrorDescription
Invalid request formatRequest payload is malformed
Invalid subaccountSubaccount does not exist or is not accessible
Invalid time rangefromTime is greater than toTime
Invalid paginationlimit or offset is outside accepted bounds

symbol is a filter field, but this endpoint does not document dedicated symbol-validation errors in its handler path.