OHLC by intervals for dexrabbit

Returns one DEX trade by token on Polygon, where side currency smart contract is 0x0d50…1270, currency smart contract is 0x2791…4174 and currency smart contract is 0x0d50…1270, sorted by block time: chain ID, block time, sum of trade amount, trade price, side currency symbol, currency symbol, count and 2 more fields.

By Nadia · saved 18 June 2024 · run 5 times · Bitquery API v2

What it returns

Filters

The query

query ($network: evm_network, $interval: Int, $from: String, $till: String, $baseCurrency: String, $quoteCurrency: String) {
  EVM(network: $network, dataset: combined) {
    DEXTradeByTokens(
      orderBy: {ascendingByField: "Block_Time"}
      where: {Trade: {Side: {Currency: {SmartContract: {is: $baseCurrency}, Symbol: {}}}, Currency: {SmartContract: {is: $quoteCurrency}, Symbol: {}}, Price: {gt: 0}}, Block: {Date: {since: $from, till: $till}}}
    ) {
      ChainId
      Block {
        Time(interval: {in: minutes, count: $interval})
      }
      volume: sum(of: Trade_Amount)
      Trade {
        high: Price(maximum: Trade_Price)
        low: Price(minimum: Trade_Price)
        open: Price(minimum: Block_Number)
        close: Price(maximum: Block_Number)
        Side {
          Currency {
            Symbol
          }
        }
        Currency {
          Symbol
        }
      }
      count
    }
    token1_info: Transfers(
      where: {Transfer: {Currency: {SmartContract: {is: $baseCurrency}}}}
      limit: {count: 1}
    ) {
      Transfer {
        Currency {
          Name
          SmartContract
          Symbol
        }
      }
    }
    token2_info: Transfers(
      where: {Transfer: {Currency: {SmartContract: {is: $quoteCurrency}}}}
      limit: {count: 1}
    ) {
      Transfer {
        Currency {
          Name
          SmartContract
          Symbol
        }
      }
    }
  }
}

Variables

{
  "network": "matic",
  "baseCurrency": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
  "quoteCurrency": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
  "limit": "20",
  "interval": 15,
  "from": "2024-03-17",
  "till": "2024-06-18"
}

Similar queries