DashboardCrypto candidatesCost-Realism Labels › iter 02

iteration 02 · S1 oracle · crypto cost-realism labels · 2026-07-14

The independent referee exists — golden answer sheets committed for BTC + ETH S1 DONE

← campaign board · ← iter 01 · issue #614

In plain language — what happened this iteration

The problem with testing math: if the same person writes the calculation and the test, a mistake in their thinking appears in both — and the test passes anyway. The fix is an oracle: a second, independent program that computes the same answers a slower but transparently-simple way. Today we wrote that oracle in Python (about 300 lines) and ran it over 20,002 real trades — 10,001 Bitcoin and 10,001 Ethereum trades from the morning of 2025-09-01.

What it computes, for every bar: imagine your trading signal fires, but your order takes up to 3 seconds to reach the exchange. What's the worst price a buyer would hit in those 3 seconds? The worst for a seller? What was the fair average price (two flavors: time-weighted and volume-weighted)? What price "arrived" right when your 3 seconds were up? Then the same worst-case questions for getting OUT of the trade 3 seconds later, and finally the total round-trip cost — including Binance's real VIP5 fee with the BNB discount, which we re-verified today at 0.02325% per side rather than trusting old notes.

The result: 451 Bitcoin bars and 859 Ethereum bars now have their eight labels computed and frozen into two "golden answer sheet" CSV files, committed to the repository. Sanity held everywhere: the worst buy price was never below the average, the average never below the worst sell, and round-trip costs came out at realistic 4.6–15.7 basis points. The files are tamper-proof: the oracle refuses to run if the input data's digital fingerprint (SHA-256) changes by even one byte.

What's next: the fast production version of the same math, written in Rust. It must match these answer sheets exactly — bit for bit on the worst-price/arrival picks, and to within a billionth on the averages.

Grounded this iteration

scripts/gen_labels_oracle.py (clean-room numpy; mirrors gen_bartels_oracle.py: SYMBOLS sha-pin dict, 8-dp quantize() drift guard rc=2 on BOTH price and qty, strict-TID guard, LABELS_{BTC,ETH}_OUT redirects, repr() full-float64 rows). Bar anchors from the real OpenDeviationBarProcessor at 2 dbps (trade-driven-test convention; hermetic — no ClickHouse/network). Windows per ADR D4: entry tid>last ∧ ts<close+3e6, exit [close+3e6, close+6e6), breach excluded by TID. Pinned formula decisions: TWAP mirrors forex HorizonAccum::ingest (right-endpoint Σp·Δt/ΣΔt, first tick weightless, Δt=0 skipped, last-print fallback); VWAP true Σ(p·q)/Σq; arrival = FIRST print of the exit window (HANDOFF §3.1 pinned over forex code); roundtrip = (worst_buy − exit_worst_sell)/arrival×1e4 + 2×2.325 bps, denominator arrival_price because the D5 DEFAULT expression must be pure over label-table columns (forex's bid_close is same-table only because forex labels are inline). Only MATURE bars emitted (close+6s ≤ last fixture ts). Fee re-pinned 2026-07-14: VIP5 taker 0.0310% × 0.75 BNB = 2.325 bps/side.

BTC mature bars451 / 462
ETH mature bars859 / 920
quantize drift0
monotonicity100% held
fee (per side)2.325 bps
roundtrip range4.58–15.73 bps

Artifacts + integrity pins

ArtifactSHA-256Note
tests/fixtures/BTCUSDT-cost-realism-oracle-sample-10k.csvb1f08e0b6f71f795…451 rows × 8 labels; becomes the locked BTC ORACLE_SHA256 const in the Rust parity gate
tests/fixtures/ETHUSDT-cost-realism-oracle-sample-10k.csvc8c1b0e070d90469…859 rows × 8 labels; ETH const
scripts/gen_labels_oracle.pycommitted this iterationfail-closed: input-sha pin, 8-dp drift==0, strict TID; ABORTs on any NaN over mature bars

Decisions made (for operator review at PR time)

#DecisionWhy
1Roundtrip denominator = arrival_price (not bar close)D5 requires a pure same-table DEFAULT expression; arrival is the canonical TCA shortfall reference and NULL-consistent with the exit leg. Forex's bid_close was same-table only because its labels are inline.
2Arrival = first print of the exit window [close+3s, close+6s)HANDOFF §3.1 "first trade at/after close+H" pinned (ADR §5); bounded by the same 6s the runner's day-boundary carry guarantees — unbounded scan is ill-defined.
3TWAP = forex right-endpoint rule with last-print fallbackADR is silent on TWAP weighting; the named forex reference (pending_queue.rs:72-97,128-131) is the SSoT to mirror.
4Oracle threshold = 2 dbps; only mature bars emittedCommitted trade-driven-test convention (462/920 bars from 10k trades); truncated tail windows are runner/watermark concerns, not kernel semantics.
5Fee constant re-pinned: 2.325 bps/side (VIP5 taker 0.0310% × 0.75 BNB), 2026-07-14, binance.com/en/fee/spotMakerADR D5: never trust the handoff estimate blindly (it matched: 0.02325%/side).

Next fire picks up here

S2–S3 — production Rust kernel. New module in opendeviationbar-core computing all 8 labels from (bar anchors × forward tick slice); parity test vs the committed oracle CSVs with locked ORACLE_SHA256 consts — TOL=0 (bit-exact) on worst_buy/worst_sell/arrival/exit fills, ≤1e-9 on twap/vwap/roundtrip; plus Leg 2 (in-Rust brute-force re-scan) and Leg 3 (property battery + hand-built empty-window→NULL unit test). Branch feat/labels/pr-a-oracle.