Issues with data

If you run the query below then buyAmount and sellAmount look quite normal at first but then when it gets to about 9:00 the figures go up by a lot They’re like 2 quadrillion times bigger. The numbers are around 1,500,000 and they go to 3,488,121,484,375,000,000,000. They mix between big ones and small ones for a while before they gradually become mostly the big ones. I’m using the v1 API, will this be the same in v2?

{
ethereum(network: ethereum) {
dexTrades(
date: {is: “2024-02-06”}
options: {asc: “timeInterval.minute”}
exchangeName: {in: [“Uniswap”]}
) {
sellAmount(in: USD)
buyAmount(in: USD)
timeInterval {
minute(count: 2)
}
exchange {
name
fullName
}
tradeAmount(in: USD)
}
}
}

I know nobody’s replied to my original question but I’ve been working on trying to duplicate this in V2, but I’m struggling to understand it.

  1. How do I query between two dates/times? I can see “since”, “till”, etc, but they seem to be using the OR condition and pulling way too much data.

  2. There seems to be two places to filter by date/time, what’s the difference?
    EVM > DEXTrades > where > any > Block > Time
    and
    EVM > DEXTrades > Block > Time
    Which should I use?

Wrt amount, does it not depend on the token that’s being bought/sold? Could be random tokens. But values like 3,488,121,484,375,000,000,000 look odd. Can you create a ticket at support.bitquery.io ?

@twinnie since/till does not use OR condition. if you use both, then they are applied.
Any is OR condition. Filtering | Blockchain Data API (V2)

Block → time is much more granular since it filters between timestamp A& B.
But Block-> date filters between two dates A&B

  1. To query between two dates/times, you can use the since and till which does consume slightly more points. Additionally you can try to use the filter of after and before to check. It does use slightly lesser points.
  2. You should ideally use EVM > DEXTrades > Block > Time since the any function is a way to have or conditions added. So if you filter through Or without any additional arguement, then you would still get the data with the date filtered out. But it would cost more since its an OR function that would be taking place

Thanks, I’ll open a ticket about the data thing. It’s supposed to be returning the results in USD and it’s showing like two sextillion dollars of volume in two minutes so there must be something wrong. I’ve been using that query for months and it’s always seemed fine.

Those details on the results are helpful, I’ll take another look. I didn’t look too far into the results I was getting but it was showing the first result coming in from 2017 but if you say it’s not supposed to be doing that I’ll double check what I’m doing.

Thanks.

Sorry to bump this thread but I’m revisiting it and trying to figure out how to translate my queries to v2. I’ve also raised that bug and got a reply to say they’d look at it but heard nothing since. I checked the query again a little while ago and it still wasn’t working.

Anyway, can somebody take a look at this query and tell me where I’m going wrong. I’m just trying to test pulling data from only between the two dates but when I run the query it pulls all the data from 2017 and onwards:

query MyQuery {
EVM(dataset: archive, mempool: false, network: eth) {
DEXTrades {
Block {
Time(
interval: {count: 10}
selectWhere: {till: “2023-04-28T10:32:00+00:00”, since: “2023-04-28T09:32:00+00:00”}
)
}
}
}
}

Okay, an update to say I now have my query working. Unfortunately the problem is still present in v2:

  {
    "Block": {
      "Time": "2023-04-25T20:00:00Z"
    },
    "Trade": {
      "Buy": {
        "AmountInUSD": "4964079.243271434"
      },
      "Sell": {
        "AmountInUSD": "286593996718948120000"
      }
    }
  }

@twinnie can you share the full query here?

Here’s my full query:

query MyQuery {
EVM(dataset: archive, network: eth) {
DEXTrades(
where: {Block: {Time: {till: “2024-04-30T10:00:00Z”, since: “2024-04-28T10:00:00Z”}}}
) {
Block {
Time(interval: {in: hours, count: 1})
}
Trade {
Buy {
AmountInUSD(maximum: Trade_Buy_AmountInUSD)
}
Sell {
AmountInUSD(maximum: Trade_Sell_AmountInUSD)
}
}
}
}
}

I tried setting the time window other ways but couldn’t get it to work, it just kept starting from around 2017.

Thanks again for the help.

@twinnie check this query

query MyQuery {
  EVM(dataset: archive, network: eth) {
    DEXTrades(
      where: {Block: {Time: {till: "2024-04-30T10:00:00Z", since: "2024-04-28T10:00:00Z"}}}
       orderBy: {descendingByField: "Block_testfield"}
    ) {
      Block {
        testfield: Time(interval: {in: hours, count: 1})
      }
      Trade {
        Buy {
          AmountInUSD(maximum: Trade_Buy_AmountInUSD)
        }
        Sell {
          AmountInUSD(maximum: Trade_Sell_AmountInUSD)
        }
      }
    }
  }
}

Hello, there are times when certain tokens create problems with the USD price because of bad trades.

You can single them out manually; here is an example.

Here, you can see currencies that have unusual trade volumes. Therefore, you remove them from your query.

by adding following

any: [ {Trade: {Buy: {Currency: {SmartContract: {notIn: ["currecny1", "currency2"]}}}}}, {Trade: {Sell: {Currency: {SmartContract: {notIn: ["currecny1", "currency2"]}}}}} ]
In addition, you can use PriceAsymmetry.

PriceAsymmetry: {le: 0.01}

Which help you reduce noise,

I’m just fiddling with this whenever I get a chance and it looks like you’re on the right track. I found a token called XRGB (address: 0x5cc5e64ab764a0f1e97f23984e20fd4528356a6a) and it appears to be causing some problems. I’m not sure if it’s the only one so I’ll keep looking. I like the idea of simply filtering trades over a certain amount as that should protect from future problems as well.

Edit
Filtering out just that one currency didn’t do anything. I capped it so that it excluded trades over $1,000,000 and it seems to have solved the problem. I don’t know what’s causing it but thanks for the help. This little project of mine can continue now.

I don’t know if this is needed by anyone but here’s an example of a problematic trade:

    "Block": {
      "testfield": "2024-04-30T08:34:00Z"
    },
    "Trade": {
      "Buy": {
        "AmountInUSD": "97350947203340650000",
        "Currency": {
          "ProtocolName": "erc721",
          "SmartContract": "0x5cc5e64ab764a0f1e97f23984e20fd4528356a6a"
        },
        "PriceInUSD": 1.0103220890816081e-19
      },
1 Like

Just trying to dig into this project again I found that the code I was using actually wasn’t working. I used the solution given by Divya as I liked to idea of being able to limit the inclusion of trades above a certain size. I didn’t want a random trade skewing the data and I also liked being able to specify the size so I could make it consistent.

Or at least that’s how I thought it was going to work. When I ran it I actually found that rather than removing trades that were over $1,000,000 it just sort of stopped counting when it reached around $1,000,000, so all the results were just below that figure. Is it possible to get this working the way I’d like it working?

Here’s my test code:

query MyQuery {
EVM(dataset: archive, network: eth) {
DEXTrades(
where: {Block: {Time: {till: “2024-02-07T00:00:00Z”, since: “2024-02-06T00:00:00Z”}}, Trade: {Buy: {Currency: {}, AmountInUSD: {le: “1000000”}}, Sell: {AmountInUSD: {lt: “1000000”}}}}
orderBy: {descendingByField: “Block_testfield”}
) {
Block {
testfield: Time(interval: {in: days, count: 1})
}
Trade {
Buy {
AmountInUSD(maximum: Trade_Buy_AmountInUSD)
}
Sell {
AmountInUSD(maximum: Trade_Sell_AmountInUSD)
}
}
}
}
}

Hello @twinnie can you create a support ticket for the same?

Hi @Divya
I created a support ticket for this a while ago but haven’t heard anything. Are you able to see what happened to it?
Thanks.