SmartStake commited on
Commit
1e72f5f
·
verified ·
1 Parent(s): 1b5a652

College football mainline odds (2026), the dataset behind The Closing Line issue 7

Browse files
Files changed (45) hide show
  1. README.md +128 -0
  2. kick_day=2026-08-27/data.parquet +3 -0
  3. kick_day=2026-08-28/data.parquet +3 -0
  4. kick_day=2026-08-29/data.parquet +3 -0
  5. kick_day=2026-09-03/data.parquet +3 -0
  6. kick_day=2026-09-04/data.parquet +3 -0
  7. kick_day=2026-09-05/data.parquet +3 -0
  8. kick_day=2026-09-06/data.parquet +3 -0
  9. kick_day=2026-09-07/data.parquet +3 -0
  10. kick_day=2026-09-10/data.parquet +3 -0
  11. kick_day=2026-09-11/data.parquet +3 -0
  12. kick_day=2026-09-12/data.parquet +3 -0
  13. kick_day=2026-09-17/data.parquet +3 -0
  14. kick_day=2026-09-18/data.parquet +3 -0
  15. kick_day=2026-09-19/data.parquet +3 -0
  16. kick_day=2026-09-24/data.parquet +3 -0
  17. kick_day=2026-09-25/data.parquet +3 -0
  18. kick_day=2026-09-26/data.parquet +3 -0
  19. kick_day=2026-10-01/data.parquet +3 -0
  20. kick_day=2026-10-02/data.parquet +3 -0
  21. kick_day=2026-10-03/data.parquet +3 -0
  22. kick_day=2026-10-06/data.parquet +3 -0
  23. kick_day=2026-10-07/data.parquet +3 -0
  24. kick_day=2026-10-08/data.parquet +3 -0
  25. kick_day=2026-10-09/data.parquet +3 -0
  26. kick_day=2026-10-10/data.parquet +3 -0
  27. kick_day=2026-10-13/data.parquet +3 -0
  28. kick_day=2026-10-14/data.parquet +3 -0
  29. kick_day=2026-10-15/data.parquet +3 -0
  30. kick_day=2026-10-16/data.parquet +3 -0
  31. kick_day=2026-10-17/data.parquet +3 -0
  32. kick_day=2026-10-20/data.parquet +3 -0
  33. kick_day=2026-10-21/data.parquet +3 -0
  34. kick_day=2026-10-22/data.parquet +3 -0
  35. kick_day=2026-10-23/data.parquet +3 -0
  36. kick_day=2026-10-24/data.parquet +3 -0
  37. kick_day=2026-10-27/data.parquet +3 -0
  38. kick_day=2026-10-28/data.parquet +3 -0
  39. kick_day=2026-10-29/data.parquet +3 -0
  40. kick_day=2026-10-30/data.parquet +3 -0
  41. kick_day=2026-10-31/data.parquet +3 -0
  42. scripts/extract_day.sh +23 -0
  43. scripts/stage1_compact.sh +46 -0
  44. scripts/xraw_day.sh +34 -0
  45. scripts/xtop_day.sql +47 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ language:
4
+ - en
5
+ pretty_name: SmartStake College Football Mainline Odds (2026)
6
+ tags:
7
+ - sports-betting
8
+ - sports-analytics
9
+ - college-football
10
+ - ncaaf
11
+ - odds
12
+ - prediction-markets
13
+ size_categories:
14
+ - 100M<n<1B
15
+ task_categories:
16
+ - time-series-forecasting
17
+ configs:
18
+ - config_name: default
19
+ data_files:
20
+ - split: train
21
+ path: "kick_day=*/*.parquet"
22
+ ---
23
+
24
+ # SmartStake College Football Mainline Odds (2026)
25
+
26
+ The exact dataset behind the study
27
+ ["Who's Actually Sharp on College Football Mainlines?"](https://smartstake.app/learn/sharpest-sportsbooks-cfb-mainlines):
28
+ every pregame price change on college football moneylines, spreads, and totals at the
29
+ twelve sportsbooks, exchanges, and prediction markets in the study, for the 1,067 games
30
+ that kicked off from 27 August through 31 October 2026. A companion to
31
+ [SmartStake MLB Mainline Odds (2026)](https://huggingface.co/datasets/SmartStake/mlb-mainlines).
32
+
33
+ ## Coverage
34
+
35
+ - **Games:** 1,067, first kickoff 27 August 2026, last kickoff 31 October 2026 (US time).
36
+ - **Window:** pregame only. Every row's price was posted before kickoff (`ts < start_ms`).
37
+ The earliest quotes date from 7 August.
38
+ - **Markets:** full-game moneyline, spread, and total, at every line each book posted
39
+ (alternate spreads and totals included, as in the study).
40
+ - **Books:** Pinnacle, Bookmaker, BetOnline, Kalshi, Polymarket, Novig, ProphetX, 4Caster,
41
+ FanDuel, DraftKings, Fanatics, and Caesars.
42
+ - **Rows:** 172,700,424 (about 1 GB of Parquet, one file per kickoff day).
43
+
44
+ ## One row is a run of one price
45
+
46
+ Books re-send an unchanged price over and over. Each row here is one run: a book's price
47
+ for one selection staying the same from `ts` (first seen) to `ts_last` (last re-sent).
48
+ A new row starts when the price, or whether it is bettable, changes. A price holds until
49
+ the next row for the same selection, so to read a book's price at time T, take the
50
+ latest row with `ts <= T`.
51
+
52
+ **Sportsbooks** (Pinnacle, Bookmaker, BetOnline, Novig, ProphetX, FanDuel, DraftKings,
53
+ Fanatics, Caesars) are at the feed's millisecond resolution.
54
+
55
+ **Kalshi, Polymarket, and 4Caster** show many resting offers at once, so their rows are
56
+ the best price you could actually bet, minute by minute: `ts` and `ts_last` fall on whole
57
+ minutes, and a row with `eff = null` marks a minute with nothing bettable. A 4Caster offer
58
+ counts as gone if it is not re-posted within 90 seconds, and a Kalshi offer under $100 is
59
+ ignored rather than treated as a pulled price.
60
+
61
+ A selection is `(matchKey, market, line, side, book, contract)`.
62
+
63
+ ## Schema
64
+
65
+ | column | type | description |
66
+ |---|---|---|
67
+ | `matchKey` | string | Per-game identity. Group on this. |
68
+ | `market` | string | `Moneyline`, `Spread`, or `Total Points`. |
69
+ | `book` | string | Sportsbook, exchange, or prediction market. |
70
+ | `contract` | string | Kalshi's contract id (Kalshi lists each team as its own contract). Empty for every other book. |
71
+ | `side` | string | `A` = home (moneyline, spread) or over (total); `B` = away or under. |
72
+ | `line` | double | `0` for moneylines; the **home** team's spread for spreads (so both sides of a spread share one `line`); the total for totals. |
73
+ | `ts` | int64 | First time this price was seen, epoch milliseconds (UTC). |
74
+ | `ts_last` | int64 | Last time the book re-sent this same price, epoch milliseconds (UTC). |
75
+ | `start_ms` | int64 | Scheduled kickoff, epoch milliseconds (UTC). |
76
+ | `home` | string | Home team. |
77
+ | `away` | string | Away team. |
78
+ | `eff` | double | The bettable decimal price. Null when the price was pulled, or when the book reported a max bet under $100. |
79
+ | `del` | bool | The book flagged the selection as removed while still showing a price (a feed refresh; it usually comes back). |
80
+ | `mx` | double | The book's reported max bet (or size at the price) when the run started, where the feed carries one. |
81
+ | `kick_day` | date | Partition key: the kickoff date, taken as kickoff time minus 8 hours in UTC (so a late-night Pacific kickoff stays on its Saturday). |
82
+
83
+ ## How it was built
84
+
85
+ 1. `scripts/extract_day.sh` pulls each day of SmartStake's raw odds archive down to
86
+ pregame NCAAF moneylines, spreads, and totals at the twelve books.
87
+ 2. `scripts/stage1_compact.sh` turns the sportsbooks' ticks into the runs above. A pulled
88
+ price (null odds, or odds of 1 or less) and a price with a reported max bet under $100
89
+ both become `eff = null`, so neither counts as a price anyone could bet.
90
+ 3. `scripts/xraw_day.sh` and `scripts/xtop_day.sql` do the same for the three exchanges,
91
+ keeping each resting offer separate and then taking the best live one each minute.
92
+
93
+ The study's other rules are applied in the analysis, not here: a new exchange price has
94
+ to hold for five minutes before it counts as a move, and a cross showing an edge above 5%
95
+ is thrown out as a bad print.
96
+
97
+ ## Notes and caveats
98
+
99
+ - **Odds are raw.** Nothing is de-vigged. The study de-vigs each book's two sides before
100
+ comparing books, except for crossed markets, which use posted prices.
101
+ - **Exchange bots are left in on purpose.** Refill-bot prints are part of what the study
102
+ measures; the five-minute hold above is how the study keeps them from counting as moves.
103
+ - **Sparse feeds.** BetOnline and Fanatics confirm their prices rarely, so a run can last
104
+ hours without the book re-sending it. Check `ts_last` before treating an old price as live.
105
+ - **No results.** Game outcomes are not included.
106
+
107
+ ## Loading
108
+
109
+ ```python
110
+ import pandas as pd
111
+ df = pd.read_parquet("hf://datasets/SmartStake/cfb-mainlines/kick_day=2026-10-03")
112
+ ```
113
+
114
+ ```sql
115
+ -- DuckDB, straight from the hub
116
+ SELECT book, count(*) FROM 'hf://datasets/SmartStake/cfb-mainlines/kick_day=*/*.parquet' GROUP BY 1;
117
+ ```
118
+
119
+ ## Provenance, license, and responsible use
120
+
121
+ Odds were collected from public sportsbook and exchange feeds. Released under
122
+ CC BY 4.0 for research and educational use. This dataset is informational and
123
+ historical: past prices do not predict future outcomes, and betting carries risk of
124
+ loss. Not affiliated with any sportsbook. 21+.
125
+
126
+ ## Citation
127
+
128
+ > SmartStake (2026). SmartStake College Football Mainline Odds (2026). Hugging Face.
kick_day=2026-08-27/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7b1d01020ae4c28c9c537cadade2c4d0ed8c8221e1049c4e750a63c06052078b
3
+ size 3137046
kick_day=2026-08-28/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6d82dce65d7d4e4dd3411d9135963a7ac01c6ec46fcec9bee69431239c6c8c95
3
+ size 4265963
kick_day=2026-08-29/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed61947c582ab7649e3336b53e85c0ea71f638958326cb86e7bf1e3a45425576
3
+ size 27907417
kick_day=2026-09-03/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9b9f83bb9c68ab654310814710a7c558c39689b60bf1cfd9bdf65d8a91798594
3
+ size 22336949
kick_day=2026-09-04/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:17039986e2228d4f8788b462b642222abdeb9e2aa4d4e69158d3e364e33f2757
3
+ size 17151482
kick_day=2026-09-05/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a616bc2871eee8e2cf9ce9c59638dfa4bfc2e23ee9d8ddf8a70e38793c82975d
3
+ size 120075599
kick_day=2026-09-06/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:539d2ec5a8f2c94710033a25cafa0b3d9b51dd2e33cb6533c502b291dcbbdcc6
3
+ size 6395831
kick_day=2026-09-07/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1cc95c6b62f47b70ba82f4298f3d72fb2c5148349a66360689b9a22f548bfdb0
3
+ size 2015416
kick_day=2026-09-10/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:26dedfab2f5b5a2bd32df6aa7b18980ba1cc203ab59c9740730a25b66a2ce3b4
3
+ size 1164353
kick_day=2026-09-11/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cf500f14fd2e6712a51240a2934c726310e86aff0061bf9be967540762b59c4d
3
+ size 13029860
kick_day=2026-09-12/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ed4ce85f85d1b7f511222a443cea5bba681f80da735047ab6f1c1873e13933da
3
+ size 194248888
kick_day=2026-09-17/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1255a0d2a35608e1d860b06d27e80ad8064f4e3097e4f9a1a62034fc96bc0933
3
+ size 1570731
kick_day=2026-09-18/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d77593044be1d8b0cf6cb7ec8b306181d86474d20a657e7b8301c7f150b1ad96
3
+ size 5517951
kick_day=2026-09-19/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:65d0bcb23d445f0568a5d0643fd06faf36b5655aae074ff14fbed264784316d4
3
+ size 101866156
kick_day=2026-09-24/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad9eaba3562c3d6d935ac66821ce8da747d8c589860af55eba809080634b1148
3
+ size 1419866
kick_day=2026-09-25/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d69e3d8ab5db441a74b2e8503187d5b161d555c000abe026182b1f50d4ec7c73
3
+ size 5881150
kick_day=2026-09-26/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e5620be2f557e5413acf16f8696c9afda5df2eefabe7dfbe8cb74c3a4c29109a
3
+ size 76639343
kick_day=2026-10-01/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:590d85a3c563e4253c566789df5cd74566993f1dbbe90a8313cc83f7480404cd
3
+ size 2702365
kick_day=2026-10-02/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:67ca046fb501254c3d0716ee74c023cd9e90f8f135af5489f291e04403d6537c
3
+ size 5052120
kick_day=2026-10-03/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1a84929e10614e67dcd976cac6417d51f30e089b2483acd97d843e4e3d6a4086
3
+ size 75484841
kick_day=2026-10-06/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a9244f13bbd1cbeb3368823c6c7ac2a5427c845af1355409bca5b1bd83000493
3
+ size 959833
kick_day=2026-10-07/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4793e228ec5858bb464874da643653a80578d6a1f86db3b66144bb149463349
3
+ size 2604273
kick_day=2026-10-08/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:60e35469db9069a1f3af3d5d0965866bd8913c12f181fafb6d69c83d28a00ef8
3
+ size 5133934
kick_day=2026-10-09/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1f032c17f9a6e39ea401d8026a59771e0c6a60ecac7339a192426483b3ce4a4c
3
+ size 7811026
kick_day=2026-10-10/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8f46f402e7d9cd87a2981560630e2b55385f38fde98dfedf7b65f89b3a9f8b81
3
+ size 65868476
kick_day=2026-10-13/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b2cb1ad03512221b2392921c0e6a77197140cb49417ab5b4e87b7f378112f03
3
+ size 2117645
kick_day=2026-10-14/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:84e48b44fe08edb4fa39ba5b2b89a7ce8d40e37f309da53dcce3dd27dd3184ab
3
+ size 1977519
kick_day=2026-10-15/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:29b440f20072d64b102f1230120312c45c21e0f8287f558b1021d6e484f08710
3
+ size 4592122
kick_day=2026-10-16/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4f763d996cf5b44234e106fc01695752c5f07921914fec3abe81dba34277da20
3
+ size 4439758
kick_day=2026-10-17/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:989748adaf4a9d722890855b393b0f0aa3816349471dcc949618ab8973672614
3
+ size 65620081
kick_day=2026-10-20/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b8a896dced7ba0c4a939cde8e7031b695a652f73de851024d1f4fe95a65572e8
3
+ size 2949313
kick_day=2026-10-21/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:86d0ef3f57fdc139acb8a215f77becac0c8848c619bcc7b3cb8c1bf9a79486fd
3
+ size 1043685
kick_day=2026-10-22/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c66d5977f98eaed70f99d3fd37600e9638b78b027460c072475060f7e344db3
3
+ size 3678154
kick_day=2026-10-23/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8c7b940a59cf5a13cf9814b7624619cc96a99ce70e908ebf6b26da173300cb4
3
+ size 7370365
kick_day=2026-10-24/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d5f3f82554971539f6e0c863bee823ab62e8b54c99bb169d29ff140747d7bfee
3
+ size 73063837
kick_day=2026-10-27/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e07258a7f4d17edbb45a7f11b24e348e2d7a826a2b4c3cdb123ca7730b520998
3
+ size 2432582
kick_day=2026-10-28/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3c4968c7e970c2fd3216d6300da4667daab1d892a702618c520525573de3a8cb
3
+ size 2659096
kick_day=2026-10-29/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:00781d25d108923766c02529416af371975ba0982510a387573c081aaf01a17e
3
+ size 3667500
kick_day=2026-10-30/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4d982ec90ab8efb285e6d8ecb54d3fc72be8c9031f4dd46c4a026c2c8fde3413
3
+ size 5960504
kick_day=2026-10-31/data.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b557a3eee1facd16cdee83e7e2bcc6140c3aa6585bb1685c5ff5c22212f73c82
3
+ size 80140520
scripts/extract_day.sh ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Extract pregame CFB full-game mainlines for the 12 study books from one day partition.
3
+ # usage: extract_day.sh 2026-09-12
4
+ D=$1
5
+ SRC=s3://smartstake-bet-updates-archive/bet_updates_archive/bet_update_v1/date=$D
6
+ FINAL=/home/stats/cfb_cross/cache/day=$D.parquet; OUT=/home/stats/cfb_cross/cache/tmp_$D.parquet
7
+ duckdb -init /home/stats/.duckdbrc_noview -c "
8
+ COPY (
9
+ SELECT matchKey, lineKey, market, bookmaker, timestamp,
10
+ epoch_ms(startDate::TIMESTAMP) AS start_ms, startDate,
11
+ homeCompetitor, awayCompetitor, selectionCompetitor, selectionLine,
12
+ selectionPoints, handicapSelectionPoints, odds, maxBetSize,
13
+ isAlt, isDeleted, nativeMarketId, nativeSelectionId, eventName, source
14
+ FROM read_parquet('$SRC/*.parquet', union_by_name=true)
15
+ WHERE league = 'ncaaf'
16
+ AND market IN ('Moneyline','Spread','Total Points')
17
+ AND bookmaker IN ('bookmaker','pinnacle','novig','prophetx','kalshi','polymarket',
18
+ 'betonline','fanduel','4caster','draftkings','fanatics','caesars')
19
+ AND NOT coalesce(isPlayer,false)
20
+ AND timestamp < epoch_ms(startDate::TIMESTAMP)
21
+ ) TO '$OUT' (FORMAT parquet, COMPRESSION zstd);
22
+ "
23
+ [ -s "$OUT" ] && mv "$OUT" "$FINAL"
scripts/stage1_compact.sh ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Compact one extracted day into effective-price change rows, partitioned by kickoff day.
3
+ # side: A = home/over, B = away/under. line: 0 (ML), home spread number, or total number.
4
+ # eff: bettable decimal price, NULL if pulled (odds null) or maxBetSize reported < $100.
5
+ # del: isDeleted row that still carries odds (feed refresh cycle; expires later if not re-added).
6
+ # ts/ts_last: first and last sighting of a run of identical prices (polled books re-log unchanged prices).
7
+ # contract: Kalshi nativeMarketId (team-specific contracts), '' for every other book.
8
+ D=$1
9
+ IN=/home/stats/cfb_cross/cache/day=$D.parquet
10
+ duckdb -init /home/stats/.duckdbrc_noview -c "
11
+ COPY (
12
+ WITH b AS (
13
+ SELECT matchKey, market, bookmaker AS book,
14
+ CASE WHEN bookmaker='kalshi' THEN nativeMarketId ELSE '' END AS contract,
15
+ CASE WHEN selectionLine IN ('hometeam','over') THEN 'A' ELSE 'B' END AS side,
16
+ CASE market WHEN 'Moneyline' THEN 0.0
17
+ WHEN 'Spread' THEN CASE WHEN selectionLine='hometeam' THEN selectionPoints ELSE -selectionPoints END
18
+ ELSE selectionPoints END AS line,
19
+ timestamp AS ts, start_ms, homeCompetitor AS home, awayCompetitor AS away,
20
+ CASE WHEN odds IS NULL OR odds <= 1 THEN NULL
21
+ WHEN maxBetSize IS NOT NULL AND maxBetSize < 100 THEN NULL
22
+ ELSE odds END AS eff,
23
+ (isDeleted AND odds IS NOT NULL) AS del,
24
+ maxBetSize AS mx,
25
+ strftime(make_timestamp((start_ms - 8*3600000)*1000), '%Y-%m-%d') AS kick_day
26
+ FROM read_parquet('$IN')
27
+ WHERE selectionLine IN ('hometeam','awayteam','over','under')
28
+ AND (market = 'Moneyline' OR selectionPoints IS NOT NULL)
29
+ ),
30
+ d AS (
31
+ SELECT *, CASE WHEN eff IS NOT DISTINCT FROM lag(eff) OVER w AND del IS NOT DISTINCT FROM lag(del) OVER w
32
+ THEN 0 ELSE 1 END AS chg
33
+ FROM b WINDOW w AS (PARTITION BY matchKey, market, line, side, book, contract ORDER BY ts)
34
+ ),
35
+ r AS (
36
+ SELECT *, sum(chg) OVER (PARTITION BY matchKey, market, line, side, book, contract ORDER BY ts
37
+ ROWS UNBOUNDED PRECEDING) AS run
38
+ FROM d
39
+ )
40
+ -- One row per run of identical (eff, del): ts = first sighting, ts_last = last re-log of that price.
41
+ SELECT matchKey, market, book, contract, side, line, min(ts) AS ts, max(ts) AS ts_last,
42
+ any_value(start_ms) start_ms, any_value(home) home, any_value(away) away,
43
+ any_value(eff) eff, any_value(del) del, arg_min(mx, ts) mx, any_value(kick_day) kick_day
44
+ FROM r GROUP BY matchKey, market, book, contract, side, line, run
45
+ ) TO '/home/stats/cfb_cross/stage1' (FORMAT parquet, COMPRESSION zstd, PARTITION_BY (kick_day), FILENAME_PATTERN 'src_${D}_{i}', OVERWRITE_OR_IGNORE);
46
+ "
scripts/xraw_day.sh ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Exchange fix, pass 1: pull one extracted day's exchange rows (4caster, polymarket, kalshi) into
3
+ # xraw/, partitioned by kickoff day like stage1. Usage: xraw_day.sh <sport dir> <day>
4
+ # lvl: one resting offer (4caster: nativeSelectionId) or price level (polymarket: "token@price");
5
+ # kalshi sends only its current top of book, so the whole contract side is one stream ('').
6
+ # eff: bettable price at that offer/level, NULL once deleted, nulled or under $100.
7
+ # Kalshi rows under $100 are dropped instead: they are $1-type orders sitting on top of the real
8
+ # price, and treating them as "pulled" made Kalshi blink in and out.
9
+ S=$1; D=$2
10
+ duckdb -bail -init /dev/null -c "
11
+ SET memory_limit='6GB'; SET threads=2;
12
+ COPY (
13
+ SELECT matchKey, market, bookmaker AS book,
14
+ CASE WHEN bookmaker='kalshi' THEN nativeMarketId ELSE '' END AS contract,
15
+ CASE WHEN bookmaker='kalshi' THEN '' ELSE coalesce(nativeSelectionId, '') END AS lvl,
16
+ CASE WHEN selectionLine IN ('hometeam','over') THEN 'A' ELSE 'B' END AS side,
17
+ CASE market WHEN 'Moneyline' THEN 0.0
18
+ WHEN 'Spread' THEN CASE WHEN selectionLine='hometeam' THEN selectionPoints ELSE -selectionPoints END
19
+ ELSE selectionPoints END AS line,
20
+ timestamp AS ts, start_ms, homeCompetitor AS home, awayCompetitor AS away,
21
+ CASE WHEN odds IS NULL OR odds <= 1 OR isDeleted THEN NULL
22
+ WHEN maxBetSize IS NOT NULL AND maxBetSize < 100 THEN NULL
23
+ ELSE odds END AS eff,
24
+ maxBetSize AS mx,
25
+ strftime(make_timestamp((start_ms - 8*3600000)*1000), '%Y-%m-%d') AS kick_day
26
+ FROM read_parquet('/home/stats/${S}/cache/day=$D.parquet')
27
+ WHERE bookmaker IN ('4caster','polymarket','kalshi')
28
+ AND market IN ('Moneyline','Spread','Total Points')
29
+ AND selectionLine IN ('hometeam','awayteam','over','under')
30
+ AND (market = 'Moneyline' OR selectionPoints IS NOT NULL)
31
+ AND timestamp < start_ms
32
+ AND NOT (bookmaker = 'kalshi' AND odds > 1 AND maxBetSize IS NOT NULL AND maxBetSize < 100)
33
+ ) TO '/home/stats/${S}/xraw' (FORMAT parquet, COMPRESSION zstd, PARTITION_BY (kick_day), FILENAME_PATTERN 'src_${D}_{i}', OVERWRITE_OR_IGNORE);
34
+ "
scripts/xtop_day.sql ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- Exchange fix, pass 2: best bettable price per exchange stream, minute by minute, for one kickoff day.
2
+ -- Tokens: @S@ (nfl_cross | cfb_cross), @K@ (kick_day)
3
+ -- Output: xtop/kick_day=@K@/ in the stage1 row shape (one row per run of an unchanged best price), so
4
+ -- the crosses step reads it in place of the exchanges' stage1 rows and the other studies build on it.
5
+ SET memory_limit='12GB'; SET threads=4;
6
+
7
+ -- 1. Each offer / price level is live from its row until its next row (an update, or a delete = NULL eff).
8
+ -- 4caster re-logs its whole book every 60 s, so an offer not re-logged within 90 s is gone.
9
+ CREATE TEMP TABLE iv AS
10
+ SELECT matchKey, market, book, contract, side, line, start_ms, home, away, eff, mx,
11
+ ts // 60000 AS m0,
12
+ (CASE WHEN book = '4caster' THEN least(coalesce(nxt, start_ms), ts + 90000)
13
+ ELSE coalesce(nxt, start_ms) END - 1) // 60000 AS m1
14
+ FROM (SELECT *, lead(ts) OVER (PARTITION BY matchKey, market, book, contract, lvl, side, line ORDER BY ts) AS nxt
15
+ FROM read_parquet('/home/stats/@S@/xraw/kick_day=@K@/*.parquet'))
16
+ WHERE eff IS NOT NULL;
17
+
18
+ -- 2. Best live price (and the stake behind it) in every minute any offer was live.
19
+ CREATE TEMP TABLE top AS
20
+ SELECT matchKey, market, book, contract, side, line, m, max(eff) AS eff, arg_max(mx, eff) AS mx,
21
+ any_value(start_ms) start_ms, any_value(home) home, any_value(away) away
22
+ FROM (SELECT *, unnest(range(m0, m1 + 1)) AS m FROM iv WHERE m1 >= m0)
23
+ GROUP BY matchKey, market, book, contract, side, line, m;
24
+
25
+ -- 3. Runs of an unchanged best price; a minute with nothing live ends the run with a NULL row.
26
+ CREATE TEMP TABLE runs AS
27
+ WITH g AS (
28
+ SELECT *, lag(eff) OVER w AS prev_eff, lag(m) OVER w AS prev_m FROM top
29
+ WINDOW w AS (PARTITION BY matchKey, market, book, contract, side, line ORDER BY m)),
30
+ c AS (SELECT *, CASE WHEN prev_m = m - 1 AND prev_eff = eff THEN 0 ELSE 1 END AS chg FROM g),
31
+ r AS (SELECT *, sum(chg) OVER (PARTITION BY matchKey, market, book, contract, side, line ORDER BY m
32
+ ROWS UNBOUNDED PRECEDING) AS run FROM c)
33
+ SELECT matchKey, market, book, contract, side, line, run, min(m) m_first, max(m) m_last,
34
+ any_value(eff) eff, arg_min(mx, m) mx, any_value(start_ms) start_ms, any_value(home) home, any_value(away) away
35
+ FROM r GROUP BY matchKey, market, book, contract, side, line, run;
36
+
37
+ COPY (
38
+ SELECT matchKey, market, book, contract, side, line, m_first * 60000 AS ts, m_last * 60000 AS ts_last,
39
+ start_ms, home, away, eff, false AS del, mx, '@K@' AS kick_day
40
+ FROM runs
41
+ UNION ALL
42
+ -- nothing live the minute after this run (and the next run doesn't start right away)
43
+ SELECT matchKey, market, book, contract, side, line, (m_last + 1) * 60000, (m_last + 1) * 60000,
44
+ start_ms, home, away, NULL, false, NULL, '@K@'
45
+ FROM (SELECT *, lead(m_first) OVER (PARTITION BY matchKey, market, book, contract, side, line ORDER BY m_first) nxt FROM runs)
46
+ WHERE coalesce(nxt, 9e18) > m_last + 1 AND (m_last + 1) * 60000 < start_ms
47
+ ) TO '/home/stats/@S@/xtop/kick_day=@K@/xtop.parquet' (FORMAT parquet, COMPRESSION zstd);