Skip to main content

Account Stats

Returns the user's lifetime trading aggregates as a single object. Replaces the Subsquid accountStats query that the account dashboard's useAccountStats hook currently depends on.

GET /account/stats
Authorization: Bearer <token>

Query Parameters​

NameTypeRequiredDescription
symbolstringNoFilter to a single market. When omitted, all markets are aggregated.

There are no date parameters; this endpoint is strictly lifetime-to-date.

Response​

{
"address": "0xabc...",
"symbol": null,
"closed_count": 87,
"wins": 54,
"losses": 33,
"realized_pnl": "1320.50",
"realized_fees": "215.30",
"volume": "152300.00",
"trade_count": 412,
"net_capital": "1080.00",
"max_capital": null
}

When the user has never traded, all numeric fields are 0 and max_capital is null. The HTTP response is 200 with this empty body — not 404.

Response Fields​

FieldTypeDescription
addressstringLower-cased wallet address from the bearer token.
symbolstring | nullEcho of the symbol query parameter.
closed_countint64Number of realized_pnl_events rows for the user.
winsint64realized_pnl_events rows with realized_pnl > 0.
lossesint64realized_pnl_events rows with realized_pnl ≤ 0.
realized_pnlDecimalSum of realized_pnl_events.realized_pnl over all time (USDT).
realized_feesDecimalSum of the user's portion of fees over trades (maker fee if user is maker, taker fee otherwise) over all time (USDT).
volumeDecimalSum of price × amount over trades where the user is maker or taker (USD).
trade_countint64Count of those trades rows.
net_capitalDecimalSum of size_in_usd over the user's currently open positions (USD). Reflects state at request time, not a historical aggregate.
max_capitalDecimal | nullPeak collateral the user has ever held. v1: always null. See v1 simplifications.

v1 simplifications​

  • max_capital is null in v1. Computing a true historical peak requires a collateral_snapshots table that we have not yet introduced. Clients should hide the row or render — rather than treating null as 0. Once the snapshot table exists, this field will be populated without changing the response shape.

Other shape changes (adding unrealized_pnl, last_trade_at, etc.) will go through the normal additive evolution; the existing fields and types in this document are stable.

Errors​

HTTPcodeWhen
500ACCOUNT_STATS_FAILEDDB error aggregating any of the constituent queries.

Error body:

{ "error": "...", "code": "..." }

Notes​

  • All money is reported as a decimal string.
  • This endpoint is meant for the account-overview header and similar always-on widgets. The constituent queries are run concurrently via tokio::try_join!.
  • Lifetime totals are computed directly from trades and realized_pnl_events. No materialized summary table is used in v1; the queries rely on (user_address) indexes already in place.