For Agents

The three feeds for crypto-shortterm and the verified venue facts (2026-06-07) that shape the strategy. Chainlink BTC/USD = settlement reference (ingested first-class). Binance = predictor + microstructure. Polymarket = the book to trade + market meta. Items marked CONFIRM are Phase-0 gates (tracked in crypto-shortterm-open-questions). Endpoint specifics live in the codebase spec/plan — see Canonical artifacts.

Working note for data sources, APIs, and venue mechanics used by crypto-shortterm.

The three feeds

FeedRoleWhat we ingest
Chainlink BTC/USDSettlement reference (resolution source)On-chain aggregator read on Polygon via Alchemy RPC (~1s poll) → cl_reports. price + report timestamp. K = open print, settle = close print. (Verified live 2026-06-08 — NOT the paid Data Streams product.)
BinancePredictor + microstructureTrade ticks (for Ŝ and σ) + L2 book (for OFI/OBI adverse-flow veto). Reliable aggressor flags.
PolymarketThe market to tradeCLOB book (top-of-book + depth) via WS; market meta / discovery via Gamma API.

Settlement is Chainlink, not Binance

The single most important fact: a Polymarket BTC 5-min Up/Down resolves on the Chainlink BTC/USD print at close vs open (close ≥ open → Up; ties → Up). Binance never settles anything — it is only the faster leading predictor of the next Chainlink print. The Binance↔Chainlink basis is therefore the core risk (largest near expiry). See Fair-value model.

Verified live end-to-end (2026-06-08, commit f50b084)

All four feeds were wired and confirmed writing to the isolated crypto_shortterm Supabase schema during a ~5-min live observe run — see crypto-shortterm-phase0-live-milestone. The live wiring:

  • Binance @trade WS → predictor price (Ŝ / basis / σ).
  • Chainlink BTC/USD on-chain on Polygon via Alchemy RPC (~1s poll) → settlement reference (K at open, settle at close, basis).
  • Polymarket market discovery via Gamma (btc-updown-5m-<300s-aligned-ts>) + CLOB /book polled ~1s → book top.
  • Clock offset via Binance server-time — lenient 5s bound for observe-only; strict 0.25s reserved for Phase-1 trading.

This resolves the prior Chainlink-Data-Streams-access blocker (the settlement read is on-chain, no paid tier).

CONFIRMED: Polymarket 5-min BTC Up/Down markets exist

Series btc-up-or-down-5m, slug btc-updown-5m-<ts>, 300-second windows — confirmed live via Gamma discovery. An earlier build wrongly pivoted to 15-minute because a timestamp-alignment bug floored the window-open ts to 900s instead of 300s; corrected. Any window-alignment / K-at-open math must floor to 300s.

Verified venue facts (2026-06-07)

Fees

  • Taker: fee = C × 0.07 × p(1−p) where C = trade size, p = price. Peaks at p = 0.5 (≈ 2.5% of notional); tiny near 0/1 (≈ 0.33¢ at p = 0.95).
    • Strategic consequence: near-expiry (price → 0/1) dodges the fee → primary regime; mid-window p ≈ 0.5 is fee-killed → skip or maker-only. This is the reason the strategy concentrates near expiry.
  • Maker: 0 fee + 20% rebate. Makes maker mode attractive earlier than a strict Phase 2 if taker economics prove marginal.
  • A taker-rebate program also exists.
  • CONFIRM: actual deduction at match via a $5 fill — docs (0.07) vs a legacy API field disagree. Observe-incompatible → gated manual step at the start of Phase 1.

Resolution & capital lock-up

  • Resolution via UMA optimistic oracle: ≥2h challenge window (+ a 50/50 dispute tail if challenged).
  • Implication: a “5-min” market locks capital ≥2h unless you sell the token on the book pre-resolution. This drives the exit rule (prefer selling before resolution — see Edge logic).
  • CONFIRM: whether these Chainlink-sourced markets use a fast automated resolver (unconfirmed). Watch one market resolve and time it.

Depth, tick, order size

  • **Touch depth ≈ 1k–$25k band.
  • Tick = 0.01 (= 2% of a 50¢ price) → the k·tick edge floor is material.
  • Min order = 5 shares (~$2.50).
  • CONFIRM: real depth during the live window across many windows (snapshots aren’t enough — Phase 0 samples /book through windows).

Order types & infrastructure

  • FOK / FAK marketable order types exist → taker is viable.
  • Public WS market data; POST /order ≈ 5000/10s → rate limits are not the bottleneck.
  • Engine restarts425 post-only (~2 min) then 503 cancel-only — must be handled as non-fatal pauses, and the circuit-breaker/kill path must know these modes.
  • Order path: EIP-712-signed HTTPS + central match + on-chain settle (~tens–hundreds of ms). Not an HFT race — latency only matters relative to Polymarket’s quote staleness.

Collateral & access

  • Collateral = pUSD on Polygon; gas sponsored via relayer. CONFIRM pUSD allowance + current contract addresses.
  • Geoblock: US / UK / much of EU / AU blocked. Hungary currently NOT blocked — but this is fragile. CONFIRM geoblock from the deployment IP + ToS on automated trading.
  • Competition heavy: ≈ $18.9M/day on BTC 5-min — the lag is actively harvested; expect residual edge only in fast, size-constrained moments.

Microstructure: compute on Binance, value on Polymarket

Polymarket trade classification is near-random

Per crypto-shortterm-prediction-research (Qin & Yang 2026, 1.2B trades): on Polymarket the tick rule / bulk-volume classification are ~50% (near-random), so OFI/CVD/VPIN built from inferred aggressor side on Polymarket flow are biased. Source all aggressor-side microstructure (OFI, OBI, CVD, lead-lag) from the Binance feed (reliable aggressor flags + L2 book + trades). This is used only for the adverse-flow veto in Rev 2, not the entry signal. Polymarket supplies the contract to value/guard; Chainlink supplies settlement.

Polymarket APIs (discovery & book)

  • Gamma API — market metadata, slugs (btc-updown-5m-<300s-aligned-ts>, series btc-up-or-down-5m), event/market rules JSON, resolution descriptions. Live discovery verified 2026-06-08. Used to discover active BTC 5-min windows and to verify the / ties→Up rule against a live market. (Window-open ts floors to 300s — a 900s floor was a bug.)
  • CLOB API/book snapshots + WS book stream (wss://ws-subscriptions-clob.polymarket.com/ws/market); FOK/FAK order placement (Phase 1).
  • Exact endpoints + probe commands are in the Phase 0 plan (Tasks 11–13).

Storage

  • Supabase Postgres — telemetry + backtest data, written async off the hot path to an isolated crypto_shortterm schema (verified live 2026-06-08). Tables seen populated: binance_ticks, cl_reports, pm_book_snaps, observations, outcomes. CONFIRM: idempotent upsert / partitioning + retention. outcomes key resolved (2026-07-03): window_id is NOT unique — it is shared across all 5 assets; the unique key is (asset, window_id), and duplicate rows exist per pair (dedupe with bool_or(resolved_up)) — see the join gotcha below.
  • Local synchronous WAL — financial state (orders/positions). This is the financial source of truth, not Supabase. See crypto-shortterm-risk-management and Architecture.

Recorder throughput — per-row inserts saturate (Phase-1 blocker)

The live run showed raw Binance ticks (~50/s) saturate the recorder’s per-row async inserts even at channel cap 20k, so rows spill instead of insert. Phase-0 mitigation: throttle raw + observation recording to 1/s (fine for 1s-cadence calibration). Phase 1 — and any finer basis/σ — needs batched / COPY inserts. Overflow may land at /tmp/crypto_shortterm_spill.jsonl. Details: 2. Recorder throughput saturates on raw Binance ticks — Phase-1 blocker.

Ad-hoc live-DB access via duckdb (no psql)

Durable pattern (2026-07-02) — homebrew duckdb reads the live Supabase DB

No psql needed. Parse SUPABASE_DB_URL into PG* env vars + PGSSLMODE=require, then:

duckdb -c "INSTALL postgres; LOAD postgres; ATTACH '' AS pg (TYPE postgres, READ_ONLY); SELECT * FROM postgres_query('pg', \$q\$ <SQL> \$q\$)"

postgres_query executes server-side (Postgres does the join/aggregation, duckdb only receives results) and the ATTACH is READ_ONLY — safe for analysis against the live crypto_shortterm schema. Used for the crypto-shortterm-algo-accuracy-audit-2026-07-02 and crypto-shortterm-fak-nomatch-root-cause-2026-07-02 queries.

Gotcha — emitted_signals.side literal changed between eras

Filter side IN ('Up','Down') or you silently mis-score the legacy era

emitted_signals.side holds 'BUY' for the Jun 25–28 v1 (UP-only) rows, then 'Up'/'Down' from the both-sides cutover on. A side='Up' comparison silently mis-classifies every legacy row — this produced a fake 15% win-rate scare on 2026-07-02 before the era filter was applied. Any win-rate / EV query over emitted_signals must filter side IN ('Up','Down') (or bound the window to the clean era ≥ 2026-06-28).

Gotcha — outcomes.window_id is shared across assets (join on (asset, window_id))

crypto_shortterm.outcomes.window_id is NOT unique — join on (asset, window_id)

The same 5-min window_id has one row per asset (btc/eth/sol/xrp/doge) because each asset resolves independently (~9,643 rows over ~5,995 distinct window_ids; (asset, window_id) is the unique key). A join keyed on window_id alone collapses all 5 assets and yields ~coin-flip labels — >50% of the merged windows had self-contradicting resolved_up. Also: outcomes has duplicate rows per (asset, window_id) → dedupe with bool_or(resolved_up) GROUP BY asset, window_id. Derive our order’s asset from pmv2_autotrade_orders.source_id: crypto_5m_algo_*btc, else split_part(source_id,'_',1). Full detail + query shape: crypto-shortterm-pnl-attribution-corrections-2026-07-03.

And use realized_pnl_usd, not resolved_up, as the P&L labelresolved_up (on-chain settle ≥ K) over-books near-tie wins vs the market’s Chainlink Data Streams settlement; it is a trading gate, not settlement truth.

Confirmed — realized_pnl_usd IS CLOB settlement truth (no backfill needed)

pmv2_autotrade_orders.realized_pnl_usd == CLOB resolution (spot-checked 2026-07-05)

Across 24 of 24 sampled windows, the CLOB tokens[].winner matched the sign of realized_pnl_usd exactly (0 mismatch). So realized_pnl_usd is the actual CLOB market resolution, net of fees (the taker fee is baked into cost_basis). The ~9–15% near-tie disagreement noise is resolved_up-only (our on-chain settle ≥ K proxy) — it does NOT touch realized_pnl_usd.

Consequence: live P&L tables built on realized_pnl_usd are label-truth-grade — no CLOB backfill required for them. A CLOB backfill only helps on-chain / resolved_up-based analyses (e.g. the dry-btc-up shadow, signal parquets). Full context: crypto-shortterm-lane-state-adverse-fill-2026-07-05.