Query editor
-- CEX株式取引の比較: Coinbase 株式perp・株価指数先物 確定UTC日次取引高-- (1) Coinbase International Exchange(INTX)株式perp: 2026-03〜2026-10-01(10/1にGlobal Derivativesへ移行して終了)-- 公開 candles API。quote出来高がないため base出来高 × OHLC4 で推計-- (2) Coinbase Global Derivatives(drb, Deribit系)株式perp: 2026-09〜。公開 get_tradingview_chart_data の cost(USDC建て約定代金)-- (3) Coinbase Derivatives(CDE, 米国CFTC)株価指数先物: futures_asset_type = STOCKS。candles の出来高 × OHLC4 × contract_size で推計WITHintx_instruments AS (SELECT json_extract_scalar(j, '$.symbol') AS api_symbol,json_extract_scalar(j, '$.base_asset_name') AS underlying_ticker,json_extract_scalar(j, '$.underlying_type') AS underlying_typeFROM (SELECT CAST(json_parse(http_get('https://api.international.coinbase.com/api/v1/instruments')) AS array(json)) AS a)CROSS JOIN UNNEST(a) AS u(j)WHERE json_extract_scalar(j, '$.underlying_type') IN ('EQUITY', 'EQUITY_ETF', 'PREIPO')AND json_extract_scalar(j, '$.type') = 'PERP'),intx_daily AS (SELECT i.api_symbol, i.underlying_ticker, i.underlying_type,CAST(from_iso8601_timestamp(json_extract_scalar(c, '$.start')) AS date) AS dt,TRY_CAST(json_extract_scalar(c, '$.volume') AS double)* (TRY_CAST(json_extract_scalar(c, '$.open') AS double) + TRY_CAST(json_extract_scalar(c, '$.high') AS double)+ TRY_CAST(json_extract_scalar(c, '$.low') AS double) + TRY_CAST(json_extract_scalar(c, '$.close') AS double)) / 4 AS daily_volume_usdFROM intx_instruments iCROSS JOIN UNNEST(CAST(json_extract(json_parse(http_get(concat('https://api.international.coinbase.com/api/v1/instruments/', i.api_symbol,'/candles?granularity=ONE_DAY&start=2026-03-01T00:00:00Z'))), '$.aggregations') AS array(json))) AS u(c)),drb_instruments AS (SELECT json_extract_scalar(j, '$.instrument_name') AS api_symbol,json_extract_scalar(j, '$.base_currency') AS underlying_ticker,upper(json_extract_scalar(j, '$.underlying_type')) AS underlying_typeFROM (SELECT CAST(json_extract(json_parse(http_get('https://drb.coinbase.com/api/v2/public/get_instruments?currency=any&kind=future')), '$.result') AS array(json)) AS a)CROSS JOIN UNNEST(a) AS u(j)WHERE json_extract_scalar(j, '$.underlying_type') IN ('equity', 'equity_etf', 'preipo')AND json_extract_scalar(j, '$.settlement_period') = 'perpetual'),drb_chart AS (SELECT i.*, json_extract(json_parse(http_get(concat('https://drb.coinbase.com/api/v2/public/get_tradingview_chart_data?instrument_name=', i.api_symbol,'&resolution=1D&start_timestamp=1788220800000&end_timestamp=',CAST(CAST(to_unixtime(current_timestamp) * 1000 AS bigint) AS varchar)))), '$.result') AS rFROM drb_instruments i),drb_daily AS (SELECT api_symbol, underlying_ticker, underlying_type,CAST(from_unixtime(tick / 1000) AS date) AS dt,cost AS daily_volume_usdFROM drb_chartCROSS JOIN UNNEST(CAST(json_extract(r, '$.ticks') AS array(bigint)), CAST(json_extract(r, '$.cost') AS array(double))) AS u(tick, cost)),cde_products AS (SELECT json_extract_scalar(j, '$.product_id') AS api_symbol,json_extract_scalar(j, '$.future_product_details.group_description') AS underlying_ticker,TRY_CAST(json_extract_scalar(j, '$.future_product_details.contract_size') AS double) AS contract_sizeFROM (SELECT CAST(json_extract(json_parse(http_get('https://api.coinbase.com/api/v3/brokerage/market/products?product_type=FUTURE&limit=500')), '$.products') AS array(json)) AS a)CROSS JOIN UNNEST(a) AS u(j)WHERE json_extract_scalar(j, '$.future_product_details.futures_asset_type') = 'FUTURES_ASSET_TYPE_STOCKS'),cde_daily AS (SELECT p.api_symbol, p.underlying_ticker,CAST(from_unixtime(TRY_CAST(json_extract_scalar(c, '$.start') AS bigint)) AS date) AS dt,