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
| Name | Type | Required | Description |
|---|---|---|---|
symbol | string | No | Filter 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
| Field | Type | Description |
|---|---|---|
address | string | Lower-cased wallet address from the bearer token. |
symbol | string | null | Echo of the symbol query parameter. |
closed_count | int64 | Number of realized_pnl_events rows for the user. |
wins | int64 | realized_pnl_events rows with realized_pnl > 0. |
losses | int64 | realized_pnl_events rows with realized_pnl ≤ 0. |
realized_pnl | Decimal | Sum of realized_pnl_events.realized_pnl over all time (USDT). |
realized_fees | Decimal | Sum of the user's portion of fees over trades (maker fee if user is maker, taker fee otherwise) over all time (USDT). |
volume | Decimal | Sum of price × amount over trades where the user is maker or taker (USD). |
trade_count | int64 | Count of those trades rows. |
net_capital | Decimal | Sum of size_in_usd over the user's currently open positions (USD). Reflects state at request time, not a historical aggregate. |
max_capital | Decimal | null | Peak collateral the user has ever held. v1: always null. See v1 simplifications. |
v1 simplifications
max_capitalisnullin v1. Computing a true historical peak requires acollateral_snapshotstable that we have not yet introduced. Clients should hide the row or render—rather than treatingnullas0. 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
| HTTP | code | When |
|---|---|---|
| 500 | ACCOUNT_STATS_FAILED | DB 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
tradesandrealized_pnl_events. No materialized summary table is used in v1; the queries rely on(user_address)indexes already in place.