ClickHouse BUILD Series

Watch it move.
Explain why.

In two and a half hours you stream public prediction-market data into your own ClickHouse Cloud service, keep a one-minute midpoint series maintained on insert, and publish a market pulse dashboard — then say whether a move came with a wider spread or faster trading.

2h30 · hands-on9 modules5 markets · 10 tokenspublic APIs · no wallet

Not a trading tutorial. A live data problem.

A public prediction market is one of the few datasets that is genuinely live, genuinely messy, and free to read. This workshop uses only the public Gamma, CLOB, and Data APIs: no wallet, no deposit, no order, and no Polymarket secret at any point.

The interesting part is not the feed, it is what the feed does to your design. The WebSocket is fast but is not a durable log, so the collector detects a quiet or stalled socket, reconnects, and polls the public CLOB book while degraded. A separate loop reconciles trades on a five-second overlap with deterministic IDs, so the same trade arriving twice lands once.

Every table is keyed for the queries you will actually run — an hour bucket first, then the token or condition you group by — and the one-minute midpoint series is maintained on insert rather than recomputed on every dashboard refresh.

hard-coded token IDsGamma discovery at startup
WebSocket as a logstall detection, reconnect, REST fallback
recompute per refreshone-minute OHLC on insert
a price that movedspread, freshness, volume context

What you walk away with

Everything you'll have running by the end.

On your own ClickHouse Cloud service, fed by public APIs. One stateless Docker container is the only thing running locally.

01

A query-driven data model

Six objects in ClickHouse Cloud: markets, price_ticks, trades, a FINAL view over them, the one-minute aggregate, and its materialized view — typed with UInt256 token IDs, exact decimals, and enums.

02

A collector that survives the feed

Heartbeat and stall detection, reconnect, CLOB REST book fallback while degraded, and a health endpoint where degraded is an honest state rather than a failure.

03

Trades reconciled, not guessed

A public trades loop on a five-second overlap with deterministic IDs, plus ReplacingMergeTree as the second safety net behind it.

04

One-minute OHLC on insert

AggregatingMergeTree holding argMin, argMax, min, max and count states, finalized with the matching Merge functions — and you compare read rows against the raw scan.

05

Four questions you can answer

Current probability, five-minute movers, spread and freshness, and volume velocity — so a move gets confidence or doubt instead of a headline.

+

A Cloud dashboard

Polymarket market pulse — five saved queries including the one-minute line chart, built entirely in the ClickHouse Cloud console. No local dashboard product.

The route · 2h30 hands-on

Nine modules, in order.

One flow, start to finish: find the markets, model them, stream them, aggregate them, then explain and publish the move.

  1. 00

    Setup

    15 min

    Prepare macOS or Ubuntu on WSL 2, install clickhousectl and the ClickHouse client, create the Cloud service, and get the preflight to print READY.

  2. 01

    Ask Gamma for the busiest active markets and learn why a condition ID and an outcome token ID are different things.

  3. 02

    Create the typed market, tick and trade tables around the filters they will serve, plus the one-minute midpoint aggregate and its materialized view.

  4. 03

    Start the collector, read its health contract, and prove rows are landing in Cloud — with fixture mode as the tested fallback for a blocked or quiet feed.

  5. 04

    Finalize the aggregate states, compare read rows against the raw equivalent, and confirm the newest minute advances with no scheduled refresh job.

  6. 05

    Four explicit queries: current probability, which outcome moved most, whether the spread is wide or the quote stale, and whether trade volume accelerated.

  7. 06

    Save the five queries under their exact names and assemble Polymarket market pulse with four current views and the one-minute line chart.

  8. 07

    Give a ClickHouse Agent the live tables and make it detect a move, investigate it against spread, freshness and volume, then referee its verdict with deterministic SQL and record what it got wrong.

  9. 08

    Wrap up

    10 min

    Capture the final proof query, stop the collector, and map the path to ClickPipes for a production relay that already publishes to a stream.

Self-paced by default. Every module names its starting point and ends with a completion check you can run yourself. live, degraded with fresh REST timestamps, and fixture are all valid teaching states — the instructor track says which one the room is in, and never calls fixture data live.

Before you join

Who it's for, and what to bring.

Who it's for audience

  • Engineers putting a live feed behind a dashboard for the first time
  • Anyone who has been asked “why did that number move?” and wants the query, not a guess
  • Teams choosing between recomputing an aggregate and maintaining it on insert
  • Comfortable with SQL, a terminal, and Docker — no market-data background needed

What to bring prerequisites

  • A laptop on macOS, or Ubuntu on WSL 2 with Docker Desktop WSL integration
  • Docker, Git, and Python 3 on the path
  • A ClickHouse Cloud organization and API key, with permission to create a service, run SQL, save queries, and create dashboards
  • Nothing from Polymarket: discovery, quotes, and trades are all public reads

How it runs format

  • 100% hands-on across nine modules — every command and query is copy-paste
  • Self-paced or facilitated, with an instructor track mirroring each module
  • ClickHouse Cloud is the only database; no local ClickHouse server runs at any point
  • A quiet market is normal, so fixture mode is tested rather than improvised

What this workshop is not scope

  • Not trading. No wallet, deposit, order, position, or financial advice — public market data only
  • Not a broker exercise. The collector writes directly, because adding Kafka would only make a small feed look distributed; module 07 covers when ClickPipes is the right answer instead
  • Not a strategy. A quote midpoint is an indicative probability from the best bid and ask, not a tradeable price
  • Not a local stack. One stateless container collects; everything else lives in ClickHouse Cloud

Ready to watch it move?

Bring a laptop with Docker and a ClickHouse Cloud organization. Leave with a live feed, a one-minute aggregate maintained on insert, and a market pulse dashboard you can point at any public market.

2h30Nine modules, each ending in a check you can run yourself.
1 minMidpoint OHLC maintained on insert, not recomputed per refresh.
0Polymarket credentials: discovery, quotes, and trades are public reads.
EN