โ€บNavigation
Dashboard โ€บ Crypto candidates โ€บ Cost-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.