-
Notifications
You must be signed in to change notification settings - Fork 0
feat: adds series event lookup, and events/ endpoints #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
bougyman
commented
Jan 5, 2026
- feat: adds event listing and searching
- adds series path and events lookup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces event listing and searching capabilities by adding new Events and Series client modules to the Kalshi API wrapper. It also refactors the Candlesticks class from the Market namespace to the Series namespace as MarketCandlesticks, establishing a clearer separation between market and series-level operations.
Key Changes
- Adds
Events::Clientfor event listing, fetching individual events, retrieving metadata, and accessing multivariate events - Adds
Series::Clientfor event-level candlesticks and forecast percentile history lookups - Refactors
kalshi_pathmethod fromListablemodule toEndpointbase class for broader reusability
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/kalshi/client.rb | Adds events and series client accessors; updates full_url to filter empty path segments |
| lib/kalshi/endpoint.rb | Adds kalshi_path class method for setting endpoint paths |
| lib/kalshi/listable.rb | Removes kalshi_path (moved to Endpoint) |
| lib/kalshi/events/client.rb | New Events API client with list, fetch, metadata, multivariate, and candlesticks methods |
| lib/kalshi/events/list.rb | New endpoint for listing and fetching events with filtering support |
| lib/kalshi/events/multivariate.rb | New endpoint for multivariate events listing |
| lib/kalshi/series/client.rb | New Series API client for event candlesticks and forecast percentile history |
| lib/kalshi/series/event_candlesticks.rb | New endpoint for event-level candlestick data |
| lib/kalshi/series/forecast_percentile_history.rb | New endpoint for event forecast percentile history |
| lib/kalshi/series/market_candlesticks.rb | Refactored from Market::Candlesticks to Series::MarketCandlesticks |
| lib/kalshi/market/client.rb | Updates candlesticks reference to use Series::MarketCandlesticks |
| test/kalshi/client_test.rb | Adds tests for new events and series client accessors |
| test/kalshi/events/client_test.rb | Tests for Events::Client methods |
| test/kalshi/events/multivariate_test.rb | Tests for multivariate events listing |
| test/kalshi/series/client_test.rb | Tests for Series::Client accessor methods |
| test/kalshi/series/event_candlesticks_test.rb | Tests for EventCandlesticks fetch method |
| test/kalshi/series/forecast_percentile_history_test.rb | Tests for ForecastPercentileHistory fetch method |
| test/kalshi/market/candlesticks_test.rb | Updates to use Series::MarketCandlesticks |
| test/kalshi/market/client_test.rb | Updates assertion for refactored candlesticks class |
| def multivariate | ||
| Multivariate.new(client) |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Events::Client methods should use memoization for consistency with the established pattern in Market::Client (lib/kalshi/market/client.rb:14-35). All methods in Market::Client use the ||= operator to cache instances. Consider adding memoization like @multivariate ||= Multivariate.new(client) for the multivariate method.
| def candlesticks | ||
| Rubyists::Kalshi::Series::EventCandlesticks.new(client) |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The candlesticks method is not tested. Following the established testing pattern in this file (tests for list, fetch, metadata, and multivariate), consider adding a test case for the candlesticks method similar to the multivariate test.
| describe '#event_candlesticks' do | ||
| it 'returns a EventCandlesticks instance' do | ||
| assert_instance_of Rubyists::Kalshi::Series::EventCandlesticks, series_client.event_candlesticks | ||
| end | ||
| end | ||
|
|
||
| describe '#forecast_percentile_history' do | ||
| it 'returns a ForecastPercentileHistory instance' do | ||
| assert_instance_of Rubyists::Kalshi::Series::ForecastPercentileHistory, series_client.forecast_percentile_history | ||
| end | ||
| end |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing memoization tests for the accessor methods. Following the pattern established in test/kalshi/market/client_test.rb (lines 14-66), where each accessor method has a corresponding test verifying that it returns the same instance on multiple calls using assert_same, consider adding these tests for event_candlesticks and forecast_percentile_history.
| raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
|
|
||
| path = "#{filter.series_ticker}/events/#{filter.ticker}/candlesticks" | ||
| query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval') |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slice method is called with string keys ('start_ts', 'end_ts', 'period_interval'), but filter.to_h likely returns a hash with symbol keys based on the Reform library's behavior. Hash#slice with string keys won't match symbol keys, which could result in an empty query_params hash. Consider using symbol keys in the slice call: filter.to_h.slice(:start_ts, :end_ts, :period_interval).
| query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval') | |
| query_params = filter.to_h.slice(:start_ts, :end_ts, :period_interval) |
| raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({}) | ||
|
|
||
| path = "#{filter.series_ticker}/events/#{filter.ticker}/forecast_percentile_history" | ||
| query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval') |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The slice method is called with string keys ('start_ts', 'end_ts', 'period_interval'), but filter.to_h likely returns a hash with symbol keys based on the Reform library's behavior. Hash#slice with string keys won't match symbol keys, which could result in an empty query_params hash. Consider using symbol keys in the slice call: filter.to_h.slice(:start_ts, :end_ts, :period_interval).
| query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval') | |
| query_params = filter.to_h.slice(:start_ts, :end_ts, :period_interval) |
| let(:base_url) { Rubyists::Kalshi.config.base_url } | ||
|
|
||
| describe '#event_candlesticks' do | ||
| it 'returns a EventCandlesticks instance' do |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use "an" instead of "a" before "EventCandlesticks" since it starts with a vowel sound. The article should match the phonetic beginning of the word.
| it 'returns a EventCandlesticks instance' do | |
| it 'returns an EventCandlesticks instance' do |
| def event_candlesticks | ||
| EventCandlesticks.new(client) | ||
| end | ||
|
|
||
| def forecast_percentile_history | ||
| ForecastPercentileHistory.new(client) | ||
| end |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Series::Client methods should use memoization, consistent with the established pattern in Market::Client (lib/kalshi/market/client.rb:14-35). All methods in Market::Client use the ||= operator to cache instances and have corresponding tests verifying this behavior (test/kalshi/market/client_test.rb:14-66). Consider adding memoization like @event_candlesticks ||= EventCandlesticks.new(client) and @forecast_percentile_history ||= ForecastPercentileHistory.new(client).