# PROVENANCE What was captured, from where, how, and which packaging decisions were made on the way. ## 1. Capture | | | |---|---| | Collector | `market_capture`, purpose-built Rust binary, record `schema_version = 1` | | Host | Single AWS EC2 instance, 16 vCPU | | Run id | `run_2026-07-29_1785357165` | | Process start | 2026-07-29T20:32:45Z (5-minute pre-roll before the first window) | | First window open | 2026-07-29T20:40:00Z (`window_ts = 1785357600`) | | Last window close | 2026-07-30T04:40:00Z (`window_ts = 1785386100` + 300 s) | | Process end | 2026-07-30T04:47:05Z | | Write path | append-only NDJSON, one file per stream per symbol per window | Scheduling parameters, verbatim from `metadata/schedule.json`: `preroll_secs = 300`, `window_lead_secs = 120` (market discovery and socket subscription start 2 minutes before open), `socket_grace_secs = 120`, `window_grace_secs = 420` (post-close drain allowance). The collector exited **non-zero** by design: its own gate requires all 96 windows clean, and 17 symbol-windows had lost their strike to REST throttling. That gate has since been satisfied by the offline backfill described in §4. ### Run counters, verbatim from the collector ``` records_written 52,007,792 records_dropped 0 bytes_written 53,229,114,382 reconnects 305 ws_errors 307 rest_errors 1,067 watchdog_trips 1 windows_clean 79 / 96 (live; 96 / 96 after backfill) ``` `records_dropped = 0` and the independently recomputed Parquet row total of 52,007,792 agree exactly, which is the strongest single statement available about capture integrity. ## 2. Endpoints and subscriptions ### Websocket | stream | endpoint | subscription | |---|---|---| | `/poly_a`, `/poly_b` | `wss://ws-subscriptions-clob.polymarket.com/ws/market` | `{"type":"market","assets_ids":[,],"custom_feature_enabled":true}` — **two independent connections per symbol-window** | | `rtds` | `wss://ws-live-data.polymarket.com` | `crypto_prices_chainlink`, filters `{"symbol":"btc/usd"}` **and** `{"symbol":"eth/usd"}` | | `coinbase_tape` | `wss://advanced-trade-ws.coinbase.com` | trades + ticker + candles + heartbeat | | `binance_spot` | `wss://stream.binance.com:9443/stream` | `btcusdt@aggTrade/btcusdt@trade/btcusdt@bookTicker/btcusdt@kline_1m/ethusdt@aggTrade/ethusdt@trade/ethusdt@bookTicker/ethusdt@kline_1m` | | `binance_fut_market` | `wss://fstream.binance.com/market/stream` | `btcusdt@aggTrade/btcusdt@markPrice@1s/btcusdt@forceOrder` | Full URLs including query strings are preserved in the `url` column of every `connected` record, and outbound subscribe frames in the `frame` column — so the subscription is part of the data, not just of this document. ### REST | channel | purpose | |---|---| | `gamma/markets` | slug → condition id → token ids | | `clob/book` | book snapshot per leg around open | | `data-api/trades` | in-window polling and post-close paginated drain | | `data-api/holders` | pre-open holder distribution | | `crypto-price/open` | the strike (`openPrice` of the window's `fiveminute` series) | | `crypto-price/close_slow`, `close_fast` | two independent settlement-close paths | | `binance/depth` | depth snapshot, `limit=5000` | | `coinbase/candles`, `binance/klines` | pre-run historical backfill | | `clob/time`, `binance/time`, `coinbase/time` | clock-offset probes with round-trip timing | ## 3. Clocks `metadata/clock.json` holds verbatim `chronyc tracking` output from run start: ``` Reference ID : A9FEA97B (169.254.169.123) Stratum : 2 System time : 0.000000161 seconds fast of NTP time Last offset : -0.000000536 seconds RMS offset : 0.000000754 seconds Root delay : 0.000129075 seconds Leap status : Normal ``` Two clocks are recorded on every row, and they are not interchangeable: - `t_arrival_ns` — `CLOCK_REALTIME`. Use for wall-clock alignment across streams and against venue timestamps. - `t_arrival_mono_ns` — `CLOCK_MONOTONIC`. **The only valid clock for durations and latencies**; it cannot step backwards under NTP correction. Venue-side timestamps are inside `payload_raw` and sit on venue clocks. Measured round-trip to venue `/time` endpoints at run start: CLOB 25.3 ms / 35.8 ms, Coinbase 132.2 ms / 128.9 ms, Binance 212.1 ms / 210.6 ms (`data/venue/clock.parquet`). ## 4. The label backfill **What went wrong live.** The `crypto-price/open` endpoint throttles hard. BTC and ETH strike polls fire at the same instant on a window boundary and compete for one rate-limit budget, so one leg could exhaust its entire poll allowance on 429s. 17 of 192 symbol-windows ended with `strike = None` — 7 BTC, 10 ETH, never both legs of the same window. Closes were unaffected in all cases. **Why it was recoverable exactly, not approximately.** A window's strike is the `openPrice` of its own `fiveminute` series, and that series stays queryable long after the window closes (`completed: true`). Offline there is no rate pressure, so requests were serialised at ≥3 s spacing with backoff. **Two independent sources, both required.** 1. **REST re-read** of `crypto-price` with `variant=fiveminute`. The variant is mandatory — the `fifteenminute` series returns a different price for the same boundary and can invert the outcome. 2. **Boundary chain.** Consecutive 5-minute boundaries share one Chainlink print, so `strike(N)` must equal `close(N-1)`. The previous window's *live-captured* close was used, making this genuinely independent of the re-read. A value was accepted only when both agreed within 1e-9 absolute. All **17/17** were accepted. As a global check, the same invariant was then tested across every consecutive pair in the release: **190/190 exact**. **Append-only discipline.** The backfill never modified a raw capture file. It wrote a new `label_backfill.json` per affected symbol-window, plus a run-level summary. Both are preserved here in `metadata/label_backfill_summary.json`, including the full REST response body behind each recovered value, so the decision is auditable rather than asserted. ## 5. Packaging decisions Each of these was a judgement call; the reasoning is recorded so it can be disagreed with. **Parquet + zstd, not compressed NDJSON.** 53.23 GB → 3.57 GB (14.9×). Plain `zstd -10` on the NDJSON reaches a similar ratio, so the compression is not the argument — the typed, columnar, predicate-pushdown-capable form is. Column projection means reading only `t_arrival_ns` costs a fraction of the file. **`payload_raw` stays an unparsed string.** The venue frame is carried byte-for-byte. This is the single most important choice in the packaging: the moment a payload is parsed into columns, every consumer inherits that parse. Order-book event decoding is exactly the analysis this dataset exists to support, so it is left to the consumer. **One schema for the whole `data/` tree.** 56 columns, the union of every stream's envelope. Columns not applicable to a stream are null and cost almost nothing under dictionary encoding. The payoff is that `ds.dataset("data")` reads everything as one table. **An explicit escape hatch.** Any envelope key outside the schema would be preserved as JSON in `extra_fields_json`. It is **null in every row of this release** — verified, not assumed. During development it caught 15 rare collector control fields (`rtt_ns`, `confirmations`, `got_close_fast`, `silence_watchdog` state and others) that a naive fixed schema would have silently dropped; they are now first-class columns. **Plain nested directories, not hive partitions.** `data/clob_ws/btc/1785357600/` rather than `sym=btc/window_ts=1785357600/`. Hive keys of those names collide with the identically-named data columns and make pyarrow refuse to merge the schema (`Unable to merge: Field sym has incompatible types: string vs dictionary<...>`). Path components mirror the columns; nothing is lost. **Big streams partitioned, small streams merged.** The CLOB websocket stays one file per symbol-window (384 files, ~8.6 MB each) so a consumer can fetch a single window. Streams with a handful of rows per window are concatenated into one file each, avoiding ~1,300 tiny files. `sym` and `window_ts` remain columns, so the merge loses nothing — but note that `stream_seq` restarts at 1 for each source file inside a merged table, so the correct grouping key for sequence checks is `(stream, window_ts)`. **429 responses retained.** Throttled REST reads are kept with their error bodies in `payload_raw`. They are evidence: they explain the backfill and they characterise the endpoint's real behaviour under load. **Metadata kept verbatim where small.** `run_manifest.json`, `schedule.json`, `clock.json`, `label_backfill_summary.json` and all 96 per-window `integrity.json` files are copied unmodified rather than re-encoded, so the collector's own account of the run survives intact alongside our re-encoding of it. **No derived feature tables.** No mid-prices, no realised volatility, no order-flow imbalance, no decoded book states. Every such quantity depends on modelling choices — sampling clock, gap handling, sign conventions — that belong to the analysis, not the archive. Shipping a plausible-looking but subtly wrong feature table would be worse than shipping none, because it would be trusted. `SCHEMA.md` documents the payload formats precisely enough to build them. ## 6. Reproducing the packaging Two scripts, run in order against the raw run directory: ``` package_dataset.py --jobs 12 # NDJSON -> Parquet + conversion manifest build_labels_and_verify.py # labels + metadata + quality report ``` `package_dataset.py` exits non-zero unless every source line is accounted for, there are zero parse failures, and `extra_fields_json` is null throughout. `build_labels_and_verify.py` exits non-zero unless all quality checks pass. Wall-clock on 16 vCPU: ~5 min conversion, ~5 min verification.