Datasets:
Download scripts/xraw_day.sh from SmartStake/cfb-mainlines: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/datasets/SmartStake/cfb-mainlines/resolve/main/scripts/xraw_day.sh
- Command line
-
hf download hf://datasets/SmartStake/cfb-mainlines/scripts/xraw_day.sh
-
curl -L -o xraw_day.sh https://huggingface.co/datasets/SmartStake/cfb-mainlines/resolve/main/scripts/xraw_day.sh
2.22 kB
| # Exchange fix, pass 1: pull one extracted day's exchange rows (4caster, polymarket, kalshi) into | |
| # xraw/, partitioned by kickoff day like stage1. Usage: xraw_day.sh <sport dir> <day> | |
| # lvl: one resting offer (4caster: nativeSelectionId) or price level (polymarket: "token@price"); | |
| # kalshi sends only its current top of book, so the whole contract side is one stream (''). | |
| # eff: bettable price at that offer/level, NULL once deleted, nulled or under $100. | |
| # Kalshi rows under $100 are dropped instead: they are $1-type orders sitting on top of the real | |
| # price, and treating them as "pulled" made Kalshi blink in and out. | |
| S=$1; D=$2 | |
| duckdb -bail -init /dev/null -c " | |
| SET memory_limit='6GB'; SET threads=2; | |
| COPY ( | |
| SELECT matchKey, market, bookmaker AS book, | |
| CASE WHEN bookmaker='kalshi' THEN nativeMarketId ELSE '' END AS contract, | |
| CASE WHEN bookmaker='kalshi' THEN '' ELSE coalesce(nativeSelectionId, '') END AS lvl, | |
| CASE WHEN selectionLine IN ('hometeam','over') THEN 'A' ELSE 'B' END AS side, | |
| CASE market WHEN 'Moneyline' THEN 0.0 | |
| WHEN 'Spread' THEN CASE WHEN selectionLine='hometeam' THEN selectionPoints ELSE -selectionPoints END | |
| ELSE selectionPoints END AS line, | |
| timestamp AS ts, start_ms, homeCompetitor AS home, awayCompetitor AS away, | |
| CASE WHEN odds IS NULL OR odds <= 1 OR isDeleted THEN NULL | |
| WHEN maxBetSize IS NOT NULL AND maxBetSize < 100 THEN NULL | |
| ELSE odds END AS eff, | |
| maxBetSize AS mx, | |
| strftime(make_timestamp((start_ms - 8*3600000)*1000), '%Y-%m-%d') AS kick_day | |
| FROM read_parquet('/home/stats/${S}/cache/day=$D.parquet') | |
| WHERE bookmaker IN ('4caster','polymarket','kalshi') | |
| AND market IN ('Moneyline','Spread','Total Points') | |
| AND selectionLine IN ('hometeam','awayteam','over','under') | |
| AND (market = 'Moneyline' OR selectionPoints IS NOT NULL) | |
| AND timestamp < start_ms | |
| AND NOT (bookmaker = 'kalshi' AND odds > 1 AND maxBetSize IS NOT NULL AND maxBetSize < 100) | |
| ) TO '/home/stats/${S}/xraw' (FORMAT parquet, COMPRESSION zstd, PARTITION_BY (kick_day), FILENAME_PATTERN 'src_${D}_{i}', OVERWRITE_OR_IGNORE); | |
| " | |