Skip to content

feat(predictions): add Kalshi as prediction market data source #1285

@koala73

Description

@koala73

Summary

Add Kalshi as a second prediction market source alongside Polymarket. Kalshi is a CFTC-regulated exchange with a comprehensive API for event contracts covering politics, economics, climate, tech, and more.

API Reference

Key Endpoints

Endpoint Purpose
GET /events List events (categories, titles)
GET /markets List markets with status filter (open/closed/settled)
GET /markets/{ticker} Market detail (prices, volume, open interest)
GET /market/{ticker}/orderbook Current bid/ask
GET /market/{ticker}/candlesticks OHLCV data

Auth & Limits

  • Auth: RSA key-pair based API keys
  • Rate limits: Tiered — check via "Get Account API Limits" endpoint
  • WebSocket: Real-time market ticker, orderbook deltas, public trades (ping/pong every 10s)
  • Demo environment: Available for testing

Data Model

  • Binary yes/no contracts (same as Polymarket)
  • Prices in cents (0-100 range) — maps directly to probability %
  • Fields: ticker, title, yes_price, volume, open_interest, close_time, settlement status

Implementation Plan

1. Proto Updates

  • Add source field to PredictionMarket message (e.g., POLYMARKET, KALSHI)
  • Add Kalshi-specific fields if needed (e.g., ticker, open_interest)

2. Backend

  • New seed script scripts/seed-kalshi-markets.mjs or extend existing seed
  • Fetch from GET /events + GET /markets (filter open, non-sports)
  • Apply same filtering logic: volume threshold, probability discrepancy >5%
  • Write to Redis under prediction:markets-bootstrap:v1 (merge with Polymarket data)
  • Consider: separate Redis key prediction:kalshi:v1 vs combined key

3. Frontend

  • Show source badge/icon on each prediction item (Polymarket vs Kalshi)
  • Kalshi URLs point to https://kalshi.com/markets/<ticker>
  • Same probability bar visualization works (both are 0-100%)

4. Considerations

  • Auth: Kalshi requires API key authentication (RSA key-pair) — need to store credentials securely
  • Rate limits: Tiered, need to respect limits and add appropriate delays
  • Dedup: Some markets may overlap with Polymarket (e.g., election outcomes) — consider dedup by similarity
  • Categories: Kalshi categories may differ from Polymarket tags — normalize to shared categories

References

  • Current Polymarket implementation: server/worldmonitor/prediction/v1/list-prediction-markets.ts
  • Prediction service: src/services/prediction/index.ts
  • Seed script: scripts/seed-prediction-markets.mjs

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions