Daily USD Trading Volume per Pair Including Crypto Quoted Pairs
Last updated: November 29, 2026
Quick Overview
Using a trades table (symbol, quote asset, price, quantity, executed_at) and an hourly table of USD reference prices per asset, compute each day's USD notional volume per trading pair, its share of that day's total, and its rank. Pairs quoted in a crypto asset such as ETHBTC must be converted to USD at the hour of the trade.
Gemini
November 29, 20260
0
0 solved
Using a trades table (symbol, quote asset, price, quantity, executed_at) and an hourly table of USD reference prices per asset, compute each day's USD notional volume per trading pair, its share of that day's total, and its rank. Pairs quoted in a crypto asset such as ETHBTC must be converted to USD at the hour of the trade.
Gemini lists USD pairs and crypto-to-crypto pairs, so a volume report that only sums price times quantity silently mixes units. This SQL screen checks joins on time buckets, window functions for share and rank, and honesty about rows that could not be priced.
What the Interviewer Expects
- Notice that price times quantity is in the quote asset, not USD
- Join to the reference price at the trade's hour, not the day's close
- Use window functions for share of day and rank
- Count and surface trades with no reference price instead of dropping them
- State the time zone used for the trading day
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you compute volume per base asset across all its pairs?
- Should maker and taker sides be counted once or twice in exchange volume?
- How would you build this incrementally for a dashboard refreshed every five minutes?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
trades(trade_id, symbol, base_asset, quote_asset, price, quantity, executed_at) holds one row per match, so each trade is counted once (not once per side). usd_prices(asset, price_hour, usd_price)...
Approach
- For each trade compute
price * quantityin the quote asset, then multiply by 1 for USD quotes or by the quote asset's USD price at the truncated hour. - Aggregate per day and symbol, also counti...