Realised Pnl, Buy volume, Sell Volume Ethereum

Historical data This query already reads history - it uses the combined dataset, which needs the historical data add-on for this chain. Without the add-on it fails with 'access restricted: your plan only allows realtime'. Drop the dataset argument to fall back to the recent window. Datasets: https:

By Kshitij Mahajan · saved 24 June 2026 · Bitquery API v2

What it returns

Filters

The query

# Historical data
#   This query already reads history - it uses the combined dataset, which
#   needs the historical data add-on for this chain.
#
#   Without the add-on it fails with 'access restricted: your plan only allows
#   realtime'. Drop the dataset argument to fall back to the recent window.
#
# Datasets:  https://docs.bitquery.io/docs/graphql/dataset/archive/
# Retention: https://docs.bitquery.io/docs/graphql/data-coverage-retention/
#
# For more info on the endpoint visit -
# https://docs.bitquery.io/docs/blockchain/Ethereum/dextrades/dex-api/
# For faster results try using indexed feilds in where and orderBy clause -
# https://docs.bitquery.io/docs/graphql/indexed-fields-reference/

query($trader: String){
  EVM(network:eth dataset: combined) {
    DEXTradeByTokens(
      where: {
        Trade: {
          Currency: {
            SmartContract: { is: "0x80029DBba7FA84bb16724a9fF6eE11c367D2FcfB" }
          }
        }
        any:[{Trade:{Buyer:{is:$trader}}},{Trade:{Seller:{is:$trader}}}]
        TransactionStatus:{ Success: true } 
        Block: { Date: { since: "2026-03-11", till: "2026-03-13" } }
      }
    ) {
      Trade {
        Currency {
          Name 
          Symbol
          SmartContract
        }
      }
      buy_volume_usd: sum(
        of: Trade_Side_AmountInUSD
        if: { Trade: {Buyer:{is:$trader} Side: { Type: { is: sell } } } }
      )
      sell_volume_usd: sum(
        of: Trade_Side_AmountInUSD
        if: { Trade: {Seller:{is:$trader} Side: { Type: { is: buy } } } }
      )
      buy_volume: sum(
        of: Trade_Amount
        if: { Trade: {Buyer:{is:$trader} Side: { Type: { is: sell } } } }
      )
      sell_volume: sum(
        of: Trade_Amount
        if: { Trade: {Seller:{is:$trader} Side: { Type: { is: buy } } } }
      )
      PnL:calculate(expression:"$sell_volume_usd - $buy_volume_usd")
      trades: count
    }
  }
}

Variables

{
  "trader": "0x0a62Bd9Ee12119a5aC4807C0970fed8B71E83163"
}

Similar queries