feat(kalshi): add market_details and market_trades gold layer#9549
feat(kalshi): add market_details and market_trades gold layer#9549
Conversation
Add two new Kalshi prediction market spells built from API bronze tables: - kalshi.market_details: market reference table joining markets_0003 with event metadata from market_details_0003. Filtered to markets with >= 100 contracts traded (6.5M of 39.8M markets, 99.7% of volume). Drops 12 universally null/constant columns (55 → 43). - kalshi.market_trades: trade-level view enriched with market metadata via inner join to market_details, filtering out dust market trades. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Rename sources from _0003 to _raw (market_trades_raw, markets_raw, market_details_raw) - Update contributor from dpettas to allelosi Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… in details - market_trades: add amount_usd (yes_price_dollars * count_fp) and _updated_at - market_details: extract category from product_metadata JSON Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…sion refresh Made-with: Cursor
|
pushed changes to make the models incremental, since larger tables. |
PR SummaryMedium Risk Overview
Also registers three new Kalshi raw sources ( Reviewed by Cursor Bugbot for commit 4f4ca39. Configure here. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Missing deduplication on event_details CTE causes row fan-out
- Added QUALIFY with ROW_NUMBER() to event_details CTE to keep only the latest row per event_ticker, preventing join fan-out and duplicate ticker rows.
Or push these changes by commenting:
@cursor push 491ff46c63
Preview (491ff46c63)
diff --git a/dbt_subprojects/daily_spellbook/models/_projects/kalshi/kalshi_market_details.sql b/dbt_subprojects/daily_spellbook/models/_projects/kalshi/kalshi_market_details.sql
--- a/dbt_subprojects/daily_spellbook/models/_projects/kalshi/kalshi_market_details.sql
+++ b/dbt_subprojects/daily_spellbook/models/_projects/kalshi/kalshi_market_details.sql
@@ -54,6 +54,7 @@
strike_period,
last_updated_ts
from {{ source('kalshi', 'market_details_raw') }}
+ qualify row_number() over (partition by event_ticker order by last_updated_ts desc) = 1
)
selectYou can send follow-ups to the cloud agent here.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4f4ca39. Configure here.
dbt_subprojects/daily_spellbook/models/_projects/kalshi/kalshi_market_details.sql
Show resolved
Hide resolved
Adds QUALIFY ROW_NUMBER() to keep only the latest row per event_ticker from market_details_raw, preventing potential duplicate ticker rows if the raw source ever contains multiple snapshots per event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…_details category (from $.category) is NULL until ingestion adds the field. competition and competition_scope are available now from product_metadata and give useful values (e.g., "Pro Football", "College Basketball (M)", "Game"). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
QUALIFY is not supported in Trino/DuneSQL. Rewrote event_details deduplication as a subquery with ROW_NUMBER() + WHERE rn = 1. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>


Summary
Adds two new Kalshi prediction market spells, transforming API-sourced bronze tables into a clean gold layer:
kalshi.market_details(TABLE): Market reference table joiningmarkets_rawwith event metadata frommarket_details_raw. Filtered to markets with >= 100 contracts traded.kalshi.market_trades(VIEW): Trade-level table enriched with market metadata via inner join tomarket_details.Design choices (bronze → gold)
functional_strike,mve_*,is_provisional,fee_waiver_expiration_time), constant (response_price_units,notional_value_dollars,price_ranges), always zero (liquidity_dollars), borderline sparse (rules_secondary,primary_participant_key,settlement_timer_seconds), internal (created_hour)Test plan
dbt compilepasses for both modelsmarket_detailsunique ontickermarket_tradesunique ontrade_id🤖 Generated with Claude Code