lokima's picture
Add files using upload-large-folder tool
28252c1 verified
|
Raw
History Blame Contribute Delete
13.2 kB

SCHEMA — data dictionary

Two layers:

  1. Event tables (data/**) — one row per captured message, all sharing a single 56-column envelope schema. The venue's own frame is carried verbatim and unparsed in payload_raw.
  2. Derived tables (labels/, metadata/) — small, typed, ready to join.

1. The envelope (every row of every file in data/)

One schema across the whole data/ tree, so pyarrow.dataset.dataset("data") reads it as one table. Columns not applicable to a given stream are null; null columns cost essentially nothing in Parquet.

1.1 Always present

column type meaning
schema_version int32 Collector record-format version (1 throughout).
record_type string feed_event (websocket / internal) or rest_response.
venue string Origin: polymarket_clob, polymarket_rtds, polymarket_gamma, polymarket_data_api, polymarket_crypto_price, coinbase, binance_spot, binance_futures, host.
stream string Logical stream. Per-window streams are <sym>/<name> (e.g. btc/poly_a); run-level venue streams are bare (e.g. binance_spot).
channel string Sub-channel within the stream — see §2.
sym string btc, eth, or null for run-level venue streams that carry both.
window_ts int64 Unix seconds of the 5-minute window open; null for run-level streams. Window closes at window_ts + 300.
stream_seq int64 1-based monotonic counter per stream file. Contiguity is the drop-detection invariant: verified gap-free and duplicate-free for every stream (see metadata/quality_report.json).
t_arrival_ns int64 Host CLOCK_REALTIME at message arrival, nanoseconds. Chrony-disciplined (§4). Use for wall-clock alignment.
t_arrival_mono_ns int64 Host monotonic clock, nanoseconds. The only valid clock for durations — immune to NTP steps.
n int64 Payload size in bytes as received.
payload_raw string The venue frame, verbatim. Not parsed, not reformatted, not re-serialised. Empty string for records that carry no payload (e.g. connected).

1.2 Websocket transport

column type meaning
conn string Connection identity, <stream>#<attempt>. Increments on reconnect, so it partitions the stream into connection epochs.
conn_msg_seq int64 Message counter within one connection. Resets on reconnect, unlike stream_seq.
connections int64 Cumulative connection count at that point.
url string Full endpoint URL including the subscription query string.
frame string Outbound frame we sent (subscribe payloads), verbatim.
error string Transport error text on read_error.
detail string Close-frame detail on server_close.
frames_this_conn, idle_ms, limit_ms int64 Silence-watchdog state when a watchdog record fires.

1.3 REST transport

column type meaning
http_status int32 HTTP status. 429 rows are retained deliberately — throttling is part of the observable record, and payload_raw then holds the error body, not JSON.
role string Why the call was made: strike, close_slow, close_fast, live_poll, final_drain, pre_open.
limit, offset, page, rows, attempt int32/int64 Pagination and retry state.
leg string up / down — which binary leg a CLOB book snapshot refers to.
token_id string ERC-1155 token id of that leg.
slug string Polymarket market slug, e.g. btc-updown-5m-1785357600.
secs_from_open float64 Signed seconds from window open (negative = before open).
secs_from_close float64 Signed seconds from window close.
stable_reads int32 Consecutive identical strike reads at that point.
taker_only bool Trades query filter.
accepted bool Whether the collector accepted this read as authoritative.
start, end int64 Requested time range (unix seconds).
granularity_secs int32 Candle granularity for backfill.
requested_start_ts, requested_end_ts int64 Backfill range.
row_order string Column order of returned candle arrays, e.g. [time,low,high,open,close,volume].
interval string Kline interval, e.g. 1m.

1.4 Collector control / annotation records

Emitted by the collector itself, not by a venue. They document decisions in-band.

column type meaning
value float64 Confirmed strike on a strike_confirmed record.
polls, http_429 int32 Poll and 429 counts behind that confirmation.
confirmations int32 Repeat reads agreeing on a close price.
next_window_open_ts int64 The next boundary, recorded when a close is confirmed.
got_close_slow, got_close_fast bool Which close paths succeeded.
t_request_ns, t_response_ns, rtt_ns int64 Clock-probe timings against venue /time endpoints.
chrony_present bool Whether chrony was running on the capture host.
extra_fields_json string Escape hatch for envelope keys outside this schema. Null in every row of this release — verified, see conversion.no_unknown_envelope_keys.

2. Streams and their channels

2.1 data/clob_ws/{sym}/{window_ts}/poly_{a,b}.parquet

Polymarket CLOB market websocket, wss://ws-subscriptions-clob.polymarket.com/ws/market, subscribed to both legs of one window's market. poly_a and poly_b are two independent simultaneous connections to the same channel — a redundant pair, so that gaps in one can be detected against the other rather than assumed absent. Agreement is measured per window in metadata/quality_report.jsondual_capture_report.

Channels: market (the order-book stream), pong, connected, subscribe, read_error, task_exit.

payload_raw for market is a JSON array of CLOB events, each with an event_type: book (full snapshot: bids/asks as {price,size} arrays, hash, timestamp), price_change, tick_size_change, last_trade_price. The timestamp inside the payload is the venue's millisecond clock; t_arrival_ns is ours. Their difference is the observable transport latency.

Directory names mirror the sym and window_ts columns. They are plain directories, not hive key=value partitions, deliberately: hive keys of those names would collide with the identically-named data columns and break schema merging.

2.2 data/clob_rest/book_rest.parquet

clob/book REST snapshots, both legs, taken around window open. Use these to anchor the websocket stream to a known-good book state.

2.3 data/trades/

file role
trades_live.parquet data-api/trades polled during the window (role=live_poll).
trades_final.parquet Post-close paginated drain (role=final_drain), the authoritative trade set. page/offset/rows describe pagination; secs_from_close how late the read was.

trades_final is the one to use for realised trade flow; trades_live shows what was observable during the window, which is what a live system would have had.

2.4 data/reference/

file contents
discovery.parquet gamma/markets responses that resolved slug → condition id → token ids.
strike.parquet Every crypto-price/open poll, including all 429s. This is the raw evidence behind each strike, and the record of the throttling that forced the backfill.
resolution.parquet crypto-price/close_slow and close_fast polls plus close_poll_done control records. Two independent close paths per window.
holders.parquet data-api/holders snapshots, pre-open.

2.5 data/venue/ — run-level, continuous across all 96 windows

file source contents
rtds.parquet wss://ws-live-data.polymarket.com Channel crypto_prices_chainlink. The settlement oracle. payload_raw = {"payload":{"data":[{"timestamp":<ms>,"value":<price>},…]}}, a batched ~1 Hz Chainlink series.
coinbase_tape.parquet wss://advanced-trade-ws.coinbase.com Channel trades+ticker+candles+hb.
binance_spot.parquet wss://stream.binance.com:9443 btcusdt+ethusdt × aggTrade, trade, bookTicker, kline_1m. Channel spot_combined.
binance_fut_market.parquet wss://fstream.binance.com btcusdt × aggTrade, markPrice@1s, forceOrder. Channel fut_market_combined.
binance_depth_snap.parquet Binance REST depth snapshots at limit=5000.
backfill.parquet Coinbase / Binance REST Historical candles fetched at run start to pre-warm history. row_order gives array column order.
clock.parquet host + venue /time Clock-offset probes against CLOB, Binance and Coinbase, with rtt_ns.

3. labels/labels.parquet — 192 rows (96 windows × 2 symbols)

The supervised target, with the full provenance of how each label was obtained.

column type meaning
window_ts, window_open_ts, window_close_ts int64 Window bounds, unix seconds.
sym string btc / eth.
slug, condition_id, token_up, token_down string Market and leg identifiers.
resolution_source string Chainlink stream URL the market settles on.
tick_size, min_order_size float64 Market microstructure params.
neg_risk bool Polymarket neg-risk flag.
strike float64 The price to beat = the window's openPrice.
close_slow, close_fast float64 Two independently polled settlement closes.
close_used float64 The close the label was computed from.
terminal_logret_bps float64 1e4·ln(close_used/strike) — signed terminal log-moneyness.
outcome string Up / Down.
outcome_rule string Up iff close >= strike (verbatim from the market text).
label_source string live (captured in-run) or backfill_rest+chain (recovered, two-source verified).
labels_agree_live bool Whether the live run's two label paths agreed.
outcome_from_slow, outcome_from_fast string Outcome under each close path.
close_paths_agree_1usd bool Whether the two closes agree within $1.
close_slow_secs_after_close, close_fast_secs_after_close float64 Read latency after window close.
strike_first_value, strike_first_seen_secs, strike_stable_secs float64 Strike settling behaviour.
strike_polls, strike_http_429 int32 Poll count and throttling behind the strike.
strike_changed_before_settling bool Whether the reported strike moved before stabilising.
backfill_chain_prev_close float64 Previous window's close, used as the independent chain check.
backfill_chain_exact_match bool Whether REST strike matched the chain value.
window_clean_live_capture bool The live run's cleanliness verdict, preserved unmodified. Note 17 symbol-windows were unclean live and are clean after backfill; this column records the original state, not the current one.

The boundary-chain invariant

Consecutive 5-minute windows share one Chainlink print, so

strike(window N) == close(window N-1)

for the same symbol. This holds across every consecutive pair in the release and is used two ways: as the second independent source for backfilled strikes, and as a global consistency check on all 192 labels (labels.boundary_chain_consistent).

4. Time and clock discipline

  • t_arrival_ns is CLOCK_REALTIME on the capture host, chrony-disciplined against the EC2 link-local NTP service. At run start: system time 161 ns fast of NTP, last offset −536 ns, RMS offset 754 ns, root delay 129 µs. Full chronyc tracking output is in metadata/clock.json.
  • t_arrival_mono_ns is CLOCK_MONOTONIC. Use it for any duration or latency — it cannot step backwards.
  • Venue-side timestamps live inside payload_raw and are on venue clocks. Cross-venue latency work must treat the two clocks separately; data/venue/clock.parquet carries round-trip probes to quantify the offset.

5. metadata/

path contents
run_manifest.json The collector's own end-of-run manifest, verbatim: per-window per-symbol detail, stream counters, run totals.
schedule.json The window schedule decided at start, verbatim.
clock.json Host clock state at start, verbatim.
label_backfill_summary.json Every backfill decision with both sources and the accept/reject verdict, verbatim.
integrity/<window_ts>.json Per-window integrity record written at finalisation, verbatim (96 files).
window_meta.parquet Per-symbol-window market metadata, including the raw Gamma and CLOB discovery responses as JSON strings.
conversion_manifest.json Every source NDJSON file with sha256, byte count, line count, parse failures, and the Parquet file it became with its own sha256 and row count.
quality_report.json All verification checks with results and supporting detail.