0
← Exercises/
Business Analytics•9 of 14
Business AnalyticsAdvancedPRO

Cross-Exchange Market Arbitrage Spread

Scenario

Quantitative market makers search for arbitrage discrepancies across crypto exchanges. An arbitrage opportunity exists when Exchange A's highest buy bid is strictly greater than Exchange B's lowest sell ask for the same currency pair.

Task
Join `exchange_orderbooks` for `exchange_a` and `exchange_b` on `pair_symbol`. Calculate: 1. `a.pair_symbol` 2. `a.best_bid` AS `exchange_a_bid` 3. `b.best_ask` AS `exchange_b_ask` 4. `(a.best_bid - b.best_ask)` AS `arbitrage_spread` 5. `spread_pct`: `ROUND(100.0 * (a.best_bid - b.best_ask) / b.best_ask, 2)` Filter for executable opportunities where `a.best_bid > b.best_ask`. Order results by `spread_pct` descending.
Expected Output Format

Executable arbitrage pairs where Exchange A bid exceeds Exchange B ask.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Cross-Exchange Market Arbitrage Spread” SQL Problem

Business Scenario

Quantitative market makers search for arbitrage discrepancies across crypto exchanges. An arbitrage opportunity exists when Exchange A's highest buy bid is strictly greater than Exchange B's lowest sell ask for the same currency pair.

Expected Output & Criteria

Executable arbitrage pairs where Exchange A bid exceeds Exchange B ask.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE exchange_orderbooks (
        feed_id INT PRIMARY KEY,
        exchange_name VARCHAR(30) NOT NULL,
        pair_symbol VARCHAR(20) NOT NULL,
        best_bid NUMERIC(10, 2) NOT NULL,
        best_ask NUMERIC(10, 2) NOT NULL
      );

Target SQL Clauses & Operators

JOINWHEREORDER BY

Want more Business Analytics practice?

Explore the full syllabus of 14 exercises, syntax guides, and interview pitfalls.

View Business Analytics Track→