如何在沙丘分析中计算利润中的BTC供应量?

问题描述 投票:0回答:1

我正在尝试在沙丘分析中计算 BTC 供应量的利润 (%)。 基于指标定义:流通供应占利润的百分比,即上次移动时价格低于当前价格的现有代币的百分比

所以我的想法是查询:

  • 特定日期的 BTC 总供应量数据集 (TOTAL_SUPPLY)
  • 以低于当前价格的价格购买的 BTC 代币数量的数据集 (TOTAL_BOUGHT_AMOUNT)

则公式为:

供应占利润的百分比 = (TOTAL_BOUGHT_AMOUNT/TOTAL_SUPPLY)*100

TOTAL_BOUGHT_AMOUNT我从表dex.trades获得的数据集,如下代码(特定日期:15/10/2023)

with
  profit as (
    select
      tx_hash,
      block_time,
      blockchain,
      token_bought_amount as bought_amount,
      amount_usd / token_bought_amount as value_per_token,
      amount_usd,
      token_bought_symbol
    from
      dex.trades
    where
      token_bought_symbol in ('ETH', 'stETH', 'WETH')
      and date_trunc('day', block_time) = timestamp '2023-10-15'
      and (amount_usd / token_bought_amount) < 2161.67 --current_price
  )

select
  sum(bought_amount)
from
  profit

但是我得到的结果有点奇怪。 我是不是理解错了什么地方?

提前谢谢!

sql blockchain bitcoin cryptocurrency dune-analytics
1个回答
0
投票

这里有几个问题:

  • 查询所有区块链(eth、arbitrum、polygon、base、optimism 等)上的 3 个代币(ETH、stETH 和 WETH),而不是 BTC
  • 仅考虑DEX(去中心化交易所)
  • 仅包括“2023-10-15”购买的
© www.soinside.com 2019 - 2024. All rights reserved.