Skip to content

Comments

Improve Kalshi REST adapter with pagination and nested markets#2

Merged
hudsonaikins merged 3 commits intomainfrom
kalshi-improvements
Sep 6, 2025
Merged

Improve Kalshi REST adapter with pagination and nested markets#2
hudsonaikins merged 3 commits intomainfrom
kalshi-improvements

Conversation

@hudsonaikins
Copy link
Contributor

Enhance Kalshi REST adapter for better market discovery.

Changes:

  • Add _paginate_events for cursor-based pagination on /events with with_nested_markets support.
  • Update get_game_markets to use events with nested markets first, flatten, fallback to /markets.
  • Update get_nfl_markets and get_cfb_markets with case-insensitive filtering and optional week filter.
  • Update get_events to support with_nested_markets and cursor parameters.
  • Remove unused KalshiAuth import.

Why:

  • Use /events with nested markets for accurate game market discovery.
  • Add pagination to avoid missing results or over-fetching.
  • Normalize string matching for case insensitivity.
  • Keep consistent transformed responses.

Testing:

  • Verified live: 3525 game markets, 2180 NFL, 163 CFB.
  • Found Chargers vs Chiefs game (4 markets).
  • Pagination and filtering working properly.

…ensitive filtering

- Add _paginate_events for cursor-based pagination on /events
- Update get_game_markets to use events with nested markets, flatten, fallback
- Update get_nfl_markets and get_cfb_markets with robust filtering and week support
- Update get_events to support with_nested_markets and cursor
- Remove unused KalshiAuth import
- Normalize string matching for case insensitivity
- Add comprehensive unit tests for edge cases: empty responses, network failures, pagination
- Enhance docstrings with example usage for new parameters
- Test coverage for _paginate_events, get_game_markets, get_nfl_markets, get_cfb_markets, get_events, health_check
@hudsonaikins hudsonaikins merged commit bc02f96 into main Sep 6, 2025
3 of 8 checks passed
@hudsonaikins hudsonaikins deleted the kalshi-improvements branch September 6, 2025 02:49
hudsonaikins added a commit that referenced this pull request Oct 11, 2025
Fixes #1 (Twitter API domain), #2 (import mismatch), #3/#13 (NumPy compatibility),
#4/#12 (Kalshi game discovery), #5 (SSL certs), #11 (WebSocket auth docs),
#14 (WebSocket market_tickers parameter)

BREAKING CHANGES: None - all changes are backward compatible

Changes:
- Fix Twitter API base URL from twitter-api.io to api.twitterapi.io
- Fix Twitter authentication headers (x-api-key format)
- Fix KalshiAPISource import name (KalshiApiSource)
- Fix get_nfl_games() and get_cfb_games() series_ticker field usage
- Add market_tickers parameter to WebSocket subscribe() method
- Add certifi dependency for SSL certificate verification
- Document NumPy <2.0 requirement with inline comments
- Add comprehensive WebSocket authentication documentation

Documentation:
- Add BUG_FIXES_COMPLETED.md with deployment guide
- Add BETA_BUGS_TRACKING.md with all bug reports
- Add SDK_FIXES_REQUIRED.md with technical specifications
- Add WEBSOCKET_INTEGRATION_GUIDE.md with usage patterns
- Add LIVE_TESTING_FINDINGS.md with test results

Testing:
- All existing tests pass
- No new linter errors
- Verified fixes address reported issues

See BUG_FIXES_COMPLETED.md for full details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant