advancepsilon commited on
Commit
9c2b0ee
·
verified ·
1 Parent(s): 9847dbb

Initial upload: 25 days of trades, windows, dense samples, orderbook snapshots

Browse files
README.md ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Oracle Disagreement Labels — Polymarket vs Kalshi 15-min crypto windows
2
+
3
+ Training and evaluation data for predicting when the two independent oracles
4
+ settling a cross-platform hedged crypto binary trade will **disagree** on
5
+ direction, causing a double-loss event.
6
+
7
+ - **Platforms**: Polymarket (settles via Chainlink Data Feeds) and Kalshi
8
+ (settles via CF Benchmarks real-time index, e.g. BRTI for BTC).
9
+ - **Asset universe**: BTC, ETH, SOL, XRP.
10
+ - **Window length**: 15 minutes, aligned to UTC `:00`, `:15`, `:30`, `:45`.
11
+ - **Data range**: 2026-04-14 → 2026-04-22 (8 days of labels; dense samples
12
+ 2026-04-19 → 2026-04-22 only, Phase 1 instrumentation shipped on Apr 19).
13
+ - **Base disagreement rate**: 5.7% across assets; 6.1% BTC / 3.9% ETH / 7.2%
14
+ SOL / 5.6% XRP.
15
+
16
+ ## Problem statement
17
+
18
+ For each 15-minute window, predict the binary target:
19
+
20
+ ```
21
+ disagreement = (poly_settled == 'UP') != (kalshi_settled == 'UP')
22
+ ```
23
+
24
+ from features observable at `T = window_close − k` seconds, where `k ∈ [60, 300]`.
25
+
26
+ **Economics drive the task, not accuracy**:
27
+
28
+ - Catching a real disagreement saves ~$12.23 on BTC, ~$4.13 on SOL, ~$4.86 on
29
+ XRP, ~$3.44 on ETH (per-asset average at current position sizing).
30
+ - A false positive costs ~$1.00 (round-trip exit friction: fees + bid-ask).
31
+ - Breakeven precision: `FP / (FP + TP)` — so ~8% on BTC, ~20% on ETH.
32
+ - **Recall matters ~15× more than precision at BTC sizing.**
33
+
34
+ The production baseline rule
35
+ `coinbase_dist_bp < 4 OR sign_flip(binance − poly_strike, coinbase − kalshi_floor)`
36
+ at T−60s on BTC gives **PPV 24%, Recall 82%, EV +$592 over 20 days** (in-house
37
+ backfill validation; see ship target in source repo docs).
38
+
39
+ ## Files
40
+
41
+ | File | Rows | Purpose |
42
+ |---|---|---|
43
+ | `windows.parquet` | 2,781 | One row per labeled window. Target: `disagreement`. |
44
+ | `dense_samples.parquet` | 28,408 | 10-s-cadence Binance + Coinbase spot prices for each window's final 5 min. |
45
+ | `orderbook_snapshots.parquet` | 15 | Per-minute book state (bid/ask/depth each side each platform) for in-flight hedged trades. Sparse — instrumentation shipped 2026-04-21. |
46
+ | `trades.parquet` | 407 | Live-traded rows with realized P&L. Useful for EV-per-window validation. |
47
+ | `stats.json` | — | Row counts, per-asset base rates, date range. |
48
+
49
+ ### `windows.parquet`
50
+
51
+ | Column | Type | Notes |
52
+ |---|---|---|
53
+ | `asset` | str | `btc` / `eth` / `sol` / `xrp` |
54
+ | `window_start` | timestamp[UTC] | Window open time |
55
+ | `window_end` | timestamp[UTC] | Window close time (target timestamp) |
56
+ | `window_ts` | int64 | Unix-seconds of `window_start`; primary join key |
57
+ | `oracle_agreed` | bool | Raw label (True = same direction on both oracles) |
58
+ | `disagreement` | bool | **Target** — `NOT oracle_agreed` |
59
+ | `poly_settled` | str | `UP` or `DOWN` per Chainlink |
60
+ | `kalshi_settled` | str | `UP` or `DOWN` per CF Benchmarks |
61
+ | `kalshi_expiration_value` | float | CF Benchmarks index value at close |
62
+ | `poly_ptb` | float | Poly strike (price-to-beat, scraped) |
63
+ | `poly_rtds` | float | Poly RTDS-reported strike (may differ from `poly_ptb` by ~$0.16 for ETH; see notes) |
64
+ | `kalshi_floor` | float | Kalshi strike |
65
+ | `strike_gap` | float | `poly_ptb − kalshi_floor` in absolute units |
66
+ | `ptb_source` | str | Where the strike came from (PTB scraper vs RTDS vs fallback) |
67
+ | `delta_ptb_vs_rtds` | float | Cross-check delta |
68
+ | `settled_at` | timestamp[UTC] | When the row was finalized |
69
+
70
+ ### `dense_samples.parquet`
71
+
72
+ Per-observation spot prices. Join to `windows` on `window_ts + asset`.
73
+
74
+ | Column | Type | Notes |
75
+ |---|---|---|
76
+ | `asset` | str | |
77
+ | `ts` | timestamp[UTC] | Sample timestamp |
78
+ | `window_id` | str | Format: `{asset}-{window_ts}` |
79
+ | `window_ts` | int64 | Join key |
80
+ | `trade_id` | str \| null | Set when an active hedged trade was in this window |
81
+ | `binance` | float | Binance spot, Chainlink proxy |
82
+ | `coinbase` | float | Coinbase spot, CF Benchmarks proxy |
83
+ | `poly_strike` | float | Chainlink-aligned strike |
84
+ | `kalshi_floor` | float | CF-Benchmarks-aligned strike |
85
+ | `secs_to_close` | int | Seconds from sample to window close |
86
+ | `sample_age_ms` | int | Staleness of the spot fetch |
87
+ | `coinbase_dist_bp` | float | `(coinbase − kalshi_floor) / kalshi_floor × 10000` — signed |
88
+ | `binance_dist_bp` | float | Same, Binance side |
89
+ | `sign_flip` | int8 | `1` if Binance and Coinbase are on opposite sides of their respective strikes |
90
+ | `cross_spot_bp` | float | `|binance − coinbase| / mid × 10000` — pre-computed cross-exchange spread |
91
+
92
+ Cadence: ~10 seconds per sample, only during the final 300 seconds of each
93
+ window (Phase 1 sampler design). Four assets sampled in parallel.
94
+
95
+ ### `orderbook_snapshots.parquet`
96
+
97
+ Best bid/ask and depth from both platforms for in-flight hedged trades,
98
+ emitted once per 60 seconds in the final 5 minutes. Sparse because the logger
99
+ shipped 2026-04-21 and has only been on for ~12 hours at dataset build time.
100
+
101
+ Columns: `asset`, `trade_id`, `window_id`, `ts`, `secs_to_close`, plus
102
+ `{poly,kalshi}_{yes,no}_{bid,ask,depth}`.
103
+
104
+ ### `trades.parquet` (sanitized)
105
+
106
+ **This file has been sanitized for external research use.** All fill
107
+ prices, position sizes, Kelly fractions, fees, sides, and dollar P&L have
108
+ been removed. What remains is derivable from public market data plus
109
+ two anonymous outcome booleans.
110
+
111
+ | Column | Type | Notes |
112
+ |---|---|---|
113
+ | `id` | uuid | Opaque row identifier |
114
+ | `matched_event_id` | str | `crypto-<asset>-15m-<asset>-updown-15m-<window_ts>` |
115
+ | `asset` | str | Derived from `matched_event_id` |
116
+ | `window_ts` | int64 | Join key matching `windows.window_ts` |
117
+ | `oracle_agreed` | bool | Label for this trade's window |
118
+ | `created_at` | timestamp[UTC] | Entry time (reveals `minute_in_window` but that's also explicit below) |
119
+ | `resolved_at` | timestamp[UTC] | Settlement time |
120
+ | `poly_strike` | float | Strike at entry (public) |
121
+ | `kalshi_strike` | float | Strike at entry (public) |
122
+ | `spot_at_trade` | float | Binance spot at entry (public) |
123
+ | `binance_spot` | float | Binance spot at entry (public) |
124
+ | `coinbase_spot` | float | Coinbase spot at entry (public) |
125
+ | `strike_gap_pct` | float | Derived: `(poly_strike − kalshi_strike) / kalshi_strike` |
126
+ | `flat_candle_move_pct` | float | Derived: spot movement since window open |
127
+ | `minute_in_window` | int | 0–14, minute at which entry occurred |
128
+ | `binance_coinbase_divergence_pct` | float | Cross-exchange spread at entry |
129
+ | `was_win` | bool | Anonymous: did this trade resolve profitably? |
130
+ | `was_double_loss` | bool | Anonymous: was this a double-loss event? |
131
+
132
+ **What's useful in this file**:
133
+ - Identify which windows were traded (`window_ts`) for selection-bias analysis.
134
+ - Compare model fire-points against real traded windows.
135
+ - Cross-check that `was_double_loss ⊆ NOT oracle_agreed` (sanity).
136
+ - Aggregate win rate for validating the EV formula.
137
+
138
+ Per-asset trade counts: BTC 176, ETH 95, XRP 68, SOL 68. Overall win
139
+ rate **89.19%**, double-loss rate **10.81%**.
140
+
141
+ **What's NOT in this file (and why)**:
142
+ - Fill prices, sizes, fees, P&L, Kelly fraction — all stripped to avoid
143
+ exposing the bot's live execution characteristics. If you need
144
+ ground-truth EV numbers, use the per-asset aggregates in the project
145
+ docs (avg DL cost: BTC −$12.23, ETH −$3.44, SOL −$4.13, XRP −$4.86;
146
+ avg FP cost ~$1.00).
147
+ - Sides (YES/NO per platform) — not needed for disagreement prediction
148
+ (the target is window-level, not side-level) and would reveal our
149
+ direction-selection logic.
150
+
151
+ ## Recommended splits
152
+
153
+ - **Walk-forward**: train on rolling N=5 days, test on next M=1 day. No single
154
+ fixed split — our live signal drifts with volatility regimes and platform
155
+ fee structure. The 2026-04-21 windows are the most recent and should
156
+ dominate the test set in every fold.
157
+ - **Never mix traded and non-traded windows within a fold**. Traded windows
158
+ (matched by `trade_id` in `dense_samples`) are a biased subset — the entry
159
+ guards specifically select near-strike windows. Use non-traded windows for
160
+ training signal, traded windows for out-of-sample realism checks.
161
+
162
+ ## Known gotchas
163
+
164
+ 1. **`poly_rtds` is unreliable on ETH**: RTDS has been measured ~$0.16 off
165
+ vs the PTB scraper's ground truth. Prefer `poly_ptb` when both are
166
+ present; fall back to `poly_rtds` + sanity-check gap only if PTB missing.
167
+ 2. **Phase 1 dense sampling started 2026-04-19**. Windows before that date
168
+ have labels but no `dense_samples` rows. Your dense-feature model is
169
+ trained + evaluated only on 2026-04-19 onward.
170
+ 3. **Pre-rotation log data is not in the bundle**. The rotated `.zst` logs
171
+ from earlier dates contain only pre-Phase-1 output without `ORACLE_SAMPLE`
172
+ lines, so re-running the ingestion script won't recover earlier dense
173
+ data. Historical reconstruction requires pulling raw exchange tick data
174
+ and simulating the Phase 1 sampling cadence.
175
+ 4. **Sampling coverage varies**. If either Binance or Coinbase fetch failed
176
+ at a tick, the sample is emitted with a `null` field. Impute or drop as
177
+ your model requires; current production rule drops.
178
+ 5. **Strike uniqueness**: `strike_snapshots` can have duplicate rows per
179
+ `(asset, window_ts)`. The build script picks the first occurrence; a more
180
+ principled approach (earliest-vs-latest) is an ablation point.
181
+ 6. **Labels are settlement-truth, not prediction-time truth**. The
182
+ `kalshi_expiration_value` in the label is the CF Benchmarks value at
183
+ close, which can differ from the same index's value at T-60s by several
184
+ basis points. Do NOT use `kalshi_expiration_value` as a feature — it
185
+ leaks the target.
186
+
187
+ ## Reproduction
188
+
189
+ This dataset was generated by:
190
+
191
+ ```bash
192
+ python3 scripts/build_oracle_disagreement_dataset.py
193
+ ```
194
+
195
+ against the production Supabase database and rotated log files. Source is in
196
+ the repo under `scripts/build_oracle_disagreement_dataset.py`.
197
+
198
+ ## License
199
+
200
+ Internal research data. Do not redistribute outside the Anthropic /
201
+ polymarket-arb project without permission.
202
+
203
+ ## Baseline EV numbers to beat
204
+
205
+ | Horizon | Rule | PPV | Recall | EV per 20d (BTC only) |
206
+ |---|---|---|---|---|
207
+ | T−60s | `coinbase_dist<4 OR sign_flip` | 24% | 82% | +$592 |
208
+ | T−120s | same rule | 18% | 64% | +$219 |
209
+ | T−300s | same rule | 11% | 52% | +$89 |
210
+
211
+ Ship target: PPV ≥ 35% at recall ≥ 70% at T−60s, AND PPV ≥ 13% at recall
212
+ ≥ 60% at T−5 min on held-out walk-forward validation.
213
+
214
+ ## Contact / questions
215
+
216
+ See `docs/architecture/oracle_disagreement_exit_guard.md` in the source repo
217
+ (especially §13–14) for the full backtest methodology and ruled-out
218
+ features.
dense_samples.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:72f33a8bd8c9de86b95a1fedf14615ffcca705b3bc6a9efbda3483aac616eb2f
3
+ size 2975216
orderbook_snapshots.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9f4b21a96b632be90865d339bc91600f6a51f345981ffc24594b6773ff5ece95
3
+ size 43431
stats.json ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "generated_at_utc": "2026-04-27T00:21:42.086793+00:00",
3
+ "rows": {
4
+ "windows": 4503,
5
+ "dense_samples": 96394,
6
+ "orderbook_snapshots": 485,
7
+ "trades": 505
8
+ },
9
+ "per_asset": [
10
+ {
11
+ "asset": "btc",
12
+ "n": 1138,
13
+ "n_disagree": 81,
14
+ "rate_pct": 7.12
15
+ },
16
+ {
17
+ "asset": "eth",
18
+ "n": 1117,
19
+ "n_disagree": 63,
20
+ "rate_pct": 5.64
21
+ },
22
+ {
23
+ "asset": "sol",
24
+ "n": 1127,
25
+ "n_disagree": 78,
26
+ "rate_pct": 6.92
27
+ },
28
+ {
29
+ "asset": "xrp",
30
+ "n": 1121,
31
+ "n_disagree": 66,
32
+ "rate_pct": 5.89
33
+ }
34
+ ],
35
+ "date_range": {
36
+ "window_start_min": "2026-04-14T00:15:00+00:00",
37
+ "window_end_max": "2026-04-27T00:15:00+00:00"
38
+ },
39
+ "dense_samples_by_asset": {
40
+ "btc": 24495,
41
+ "eth": 24301,
42
+ "sol": 23952,
43
+ "xrp": 23646
44
+ },
45
+ "trades_by_asset": {
46
+ "btc": 243,
47
+ "eth": 117,
48
+ "xrp": 73,
49
+ "sol": 72
50
+ },
51
+ "trades_win_rate": 89.7,
52
+ "trades_double_loss_rate": 9.9
53
+ }
trades.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c4f32880b9dc0ffbcc5fbae9ebd062a0f1a26eef9807af3214690f6d7df5ca78
3
+ size 66828
windows.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5e3062724b033559f1bcaf353b884597bf47a6fdee30be110d28dbf61cad0159
3
+ size 214047