Skip to main content

Account PnL Rank

Look up a single account's leaderboard rank and percentile using get_account_pnl_rank. Returns account_pnl_rank rows.

Query Structure​

query GetAccountPnlRank {
get_account_pnl_rank(
args: {
p_account_id: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
p_sort_by: "total_pnl"
}
) {
account_id
account_label
account_image
rank
percentile
total_pnl
pnl_pct
total_volume
total_position_count
win_rate
total_accounts
}
}

Function Arguments​

ArgumentTypeDescription
p_account_idStringAccount address to look up
p_sort_byStringRanking metric (e.g. "total_pnl", "pnl_pct", "win_rate")
p_term_idStringOptional term filter
p_time_filterStringOptional time filter preset

Response Fields (account_pnl_rank)​

FieldTypeDescription
account_idStringAccount address
account_labelStringDisplay name
account_imageStringProfile image URL
rankbigintLeaderboard rank position
percentilenumericPercentile ranking (0-100)
total_pnlnumericTotal profit/loss
pnl_pctnumericPnL percentage
total_volumenumericTotal trading volume
total_position_countbigintTotal number of positions
win_ratenumericWin rate across positions
total_accountsbigintTotal accounts on the leaderboard

Interactive Example​

Query

query GetAccountPnlRank {
  get_account_pnl_rank(
    args: {
      p_account_id: "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"
      p_sort_by: "total_pnl"
    }
  ) {
    account_id
    account_label
    rank
    percentile
    total_pnl
    pnl_pct
    win_rate
    total_accounts
  }
}

Variables

Click "Run Query" to execute the GraphQL query and see results

Use Cases​

Profile Rank Badge​

Display a user's rank on their profile:

import { GraphQLClient } from 'graphql-request'
import { API_URL_PROD } from '@0xintuition/graphql'

const client = new GraphQLClient(API_URL_PROD)

async function getAccountRank(accountId: string) {
const query = `
query GetAccountPnlRank {
get_account_pnl_rank(
args: {
p_account_id: "${accountId}"
p_sort_by: "total_pnl"
}
) {
rank
percentile
total_pnl
pnl_pct
total_accounts
}
}
`

const data = await client.request(query)
return data.get_account_pnl_rank[0]
}