Getting OHLC and Distinct Buys/Sells

Returns 30 DEX trades by token on BNB Chain, where side currency smart contract is 0xbb4c…095c, currency smart contract is 0xfb61…f802 and side type is buy, sorted by block time field, highest first: block time, sum of trade amount, count, currency name, side currency name and trade price.

By Akshat · saved 5 December 2024 · run 5 times · Bitquery API v2

What it returns

Filters

The query

{
  EVM(dataset: archive, network: bsc) {
    buyside: DEXTradeByTokens(
      limit: {count: 30}
      orderBy: {descendingByField: "Block_time_field"}
      where: {Trade: {Side: {Currency: {SmartContract: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}}, Amount: {ge: "0"}, Type: {is: buy}}, Currency: {SmartContract: {is: "0xfb6115445bff7b52feb98650c87f44907e58f802"}}, PriceAsymmetry: {lt: 0.1}}, Block: {Date: {since: "2023-07-01", till: "2023-08-01"}}}
    ) {
      Block {
        time_field: Time(interval: {in: days, count: 1})
      }
      volume: sum(of: Trade_Amount)
      distinctBuyer: count(distinct: Trade_Buyer)
      distinctSeller: count(distinct: Trade_Seller)
      distinctSender: count(distinct: Trade_Sender)
      distinctTransactions: count(distinct: Transaction_Hash)
      total_sales: count(
        if: {Trade: {Side: {Currency: {SmartContract: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}}}}}
      )
      total_buys: count(
        if: {Trade: {Currency: {SmartContract: {is: "0xbb4cdb9cbd36b01bd1cbaebf2de08d9173bc095c"}}}}
      )
      total_count: count
      Trade {
        Currency {
          Name
        }
        Side {
          Currency {
            Name
          }
        }
        high: Price(maximum: Trade_Price)
        low: Price(minimum: Trade_Price)
        open: Price(minimum: Block_Number)
        close: Price(maximum: Block_Number)
      }
    }
  }
}

Similar queries