Skip to content

Get Trades For Position

Retrieve trade execution history (fills) for a specific position within a subaccount. Unlike getTrades, which returns all trades for a subaccount, this endpoint filters trades to those associated with a single position identified by positionId.

Endpoint

POST https://papi.synthetix.io/v1/trade

Request

Request Format

{
  "params": {
    "action": "getTradesForPosition",
    "subAccountId": "1867542890123456789",
    "positionId": "42",
    "limit": 100,
    "offset": 0
  },
  "expiresAfter": 1704067300,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Request Parameters

Action Parameters

ParameterTypeRequiredDescription
paramsobjectYesRequest parameters wrapper
params.actionstringYesMust be "getTradesForPosition"
params.subAccountIdstringYesSubAccount ID that owns the position
params.positionIdstringYesPosition ID to retrieve trades for (numeric string)
params.limitintegerNoMaximum number of trades to return (default: 100, max: 1000)
params.offsetintegerNoNumber of trades to skip for pagination (default: 0)

Common Request Parameters

ParameterTypeRequiredDescription
nonceuint64Yes*Positive integer nonce (must be incrementing and unique per request)
signatureobjectYesEIP-712 signature object
expiresAfteruint64NoUnix milliseconds expiration timestamp (5x rate limit on stale cancels)

:::info Common Parameters These are top-level request parameters. The subAccountId parameter is specified within the params object (see each endpoint's parameter table). :::

:::info SubAccountAction Endpoints Endpoints using SubAccountAction signing (getPositions, getOpenOrders, getOrdersHistory, getTrades, getFundingPayments, getSubAccount, getSubAccounts, getDelegatedSigners, getBalanceUpdates) do not require the nonce parameter. Only signature and optional expiresAfter are needed. :::

ParameterTypeRequiredDescription
expiresAfterintegerNoOptional expiration timestamp in seconds

Response

Response Structure

FieldTypeDescription
statusstringAlways "ok" for successful requests or "error" for failures
responseobjectResponse object containing trades array and pagination info (omitted when status is "error")
response.tradesarrayArray of trade objects for the specified position
response.trades[].orderTypestringOrder type that produced this trade: "limit", "market", "stopMarket", "takeProfitMarket", "stopLimit", or "takeProfitLimit"
response.hasMorebooleanWhether more trades exist beyond current result
errorobjectError details (only present when status is "error")
request_idstringRequest tracking identifier

Success Response Examples

Trades for a Position

{
  "status": "ok",
  "response": {
    "trades": [
      {
        "tradeId": "123456789",
        "order": {
          "venueId": "1948058938469519360",
          "clientId": "cli-1948058938469519360"
        },
        "orderId": "1948058938469519360",
        "symbol": "BTC-USDT",
        "side": "buy",
        "direction": "open long",
        "orderType": "limit",
        "price": "50000.50",
        "quantity": "0.1",
        "realizedPnl": "0.00",
        "fee": "5.00",
        "feeRate": "0.001",
        "markPrice": "50025.00",
        "entryPrice": "50000.50",
        "timestamp": 1704067200500,
        "maker": false,
        "reduceOnly": false,
        "triggeredByLiquidation": false,
        "postOnly": false
      },
      {
        "tradeId": "123456790",
        "order": {
          "venueId": "1948058938469519361",
          "clientId": "cli-1948058938469519361"
        },
        "orderId": "1948058938469519361",
        "symbol": "BTC-USDT",
        "side": "buy",
        "direction": "open long",
        "orderType": "market",
        "price": "50100.00",
        "quantity": "0.05",
        "realizedPnl": "0.00",
        "fee": "2.51",
        "feeRate": "0.001",
        "markPrice": "50110.00",
        "entryPrice": "50033.67",
        "timestamp": 1704067201000,
        "maker": false,
        "reduceOnly": false,
        "triggeredByLiquidation": false,
        "postOnly": false
      }
    ],
    "hasMore": false
  },
  "request_id": "5ccf215d37e3ae6d"
}

Empty Result Set

{
  "status": "ok",
  "response": {
    "trades": [],
    "hasMore": false
  },
  "request_id": "5ccf215d37e3ae6f"
}

Trade Object

FieldTypeDescription
tradeIdstringUnique trade execution identifier
orderobjectCanonical composite order identifier
order.venueIdstringVenue-generated order identifier
order.clientIdstringOptional client-provided order identifier
orderIdstringDeprecated legacy venue identifier
orderTypestringOrder type that produced this trade: "limit", "market", "stopMarket", "takeProfitMarket", "stopLimit", or "takeProfitLimit"
symbolstringMarket symbol (e.g., "BTC-USDT")
sidestringTrade side: "buy" or "sell"
pricestringActual filled price of this trade
quantitystringActual filled quantity of this trade
realizedPnlstringRealized P&L from position closure
feestringTrading fee amount
feeRatestringFee rate applied
timestampintegerTrade timestamp (Unix milliseconds)
makerbooleantrue if maker order, false if taker
reduceOnlybooleantrue if trade reduced existing position
postOnlybooleantrue if order was post-only (maker-only)
markPricestringMark price at time of trade
entryPricestringPosition average entry price at time of trade
triggeredByLiquidationbooleantrue if triggered by liquidation
directionstringPosition direction after trade

Trade Field Explanations

FieldDescription
tradeIdUnique identifier for this specific trade execution
order.venueIdCanonical venue-generated order ID for this trade
order.clientIdOptional client-provided order ID for this trade
orderIdDeprecated legacy order ID field
orderTypeType of order that generated this trade: "limit", "market", "stopMarket", "takeProfitMarket", "stopLimit", or "takeProfitLimit"
priceActual execution price at which this trade was filled (not the mark price or entry price)
quantityActual filled quantity for this trade execution
realizedPnlProfit/loss realized from this trade
feeTrading fee charged for this execution
feeRateFee rate applied (maker/taker rate)
markPriceMark price at time of trade execution (used for unrealized P&L and liquidations)
entryPricePosition's average entry price at time of trade (weighted average of all entries)
makerWhether this trade provided liquidity (maker) or took liquidity (taker)
reduceOnlyWhether this trade reduced an existing position
triggeredByLiquidationWhether this trade was part of a liquidation
postOnlyWhether this order was post-only (maker-only)

Error Response

{
  "status": "error",
  "error": {
    "message": "positionId is required",
    "code": "VALIDATION_ERROR"
  },
  "request_id": "5ccf215d37e3ae6d"
}

Examples

Get All Trades for a Position

{
  "params": {
    "action": "getTradesForPosition",
    "subAccountId": "1867542890123456789",
    "positionId": "42"
  },
  "expiresAfter": 1704067300,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

Paginated Request

{
  "params": {
    "action": "getTradesForPosition",
    "subAccountId": "1867542890123456789",
    "positionId": "42",
    "limit": 50,
    "offset": 100
  },
  "expiresAfter": 1704067300,
  "signature": {
    "v": 28,
    "r": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
    "s": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890"
  }
}

EIP-712 Signature

const domain = {
  name: "Synthetix",
  version: "1",
  chainId: 1,
  verifyingContract: "0x0000000000000000000000000000000000000000"
};
 
const types = {
  SubAccountAction: [
    { name: "subAccountId", type: "uint256" },
    { name: "action", type: "string" },
    { name: "expiresAfter", type: "uint256" }
  ]
};
 
const message = {
  subAccountId: "1867542890123456789",
  action: "getTradesForPosition",
  expiresAfter: 0
};
 
const signature = await signer._signTypedData(domain, types, message);

Implementation Notes

  • Requires a valid subaccount ID (authenticated via EIP-712 signature)
  • positionId is required and must be a valid numeric string
  • Pagination supports up to 1000 trades per request (default: 100)
  • Offset must be non-negative
  • The direction field indicates the position effect (e.g., "open long", "close long", "open short", "close short")
  • Unlike getTrades, this endpoint does not support symbol, orderId, startTime, or endTime filters — it returns all trades for the specified position
  • The response does not include a total count field; use hasMore for pagination

Error Handling

Common Errors

ErrorDescriptionSolution
positionId is requiredMissing position IDProvide positionId in request params
positionId must be a valid numeric valueNon-numeric position IDUse a numeric string for positionId
subaccountId is requiredMissing subaccountInclude subAccountId in request params
Invalid limitLimit exceeds maximum or is negativeUse limit between 0 and 1000
Invalid offsetNegative offset valueUse offset >= 0
Authentication failedInvalid signatureVerify signature generation
Unauthorized accessNo permission for specified subAccountIdEnsure you have access to the specified subaccount
500 Internal Server ErrorTrade history contains an unrecognized direction value (e.g. "unknown", "", or any unexpected string)Indicates corrupted trade direction data on the backend that requires operator investigation. Previously these cases were silently defaulted to side: "buy" in the response.

Rate Limiting

  • Each request counts as 1 against rate limits
  • See Rate Limits for details

Next Steps