Skip to content

Conversation

@bougyman
Copy link
Member

@bougyman bougyman commented Jan 5, 2026

  • feat: adds event listing and searching
  • adds series path and events lookup

Copilot AI review requested due to automatic review settings January 5, 2026 19:17
Copy link

Copilot AI left a 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::Client for event listing, fetching individual events, retrieving metadata, and accessing multivariate events
  • Adds Series::Client for event-level candlesticks and forecast percentile history lookups
  • Refactors kalshi_path method from Listable module to Endpoint base 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

Comment on lines +20 to +21
def multivariate
Multivariate.new(client)
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +25
def candlesticks
Rubyists::Kalshi::Series::EventCandlesticks.new(client)
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +20
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
Copy link

Copilot AI Jan 5, 2026

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.

Copilot uses AI. Check for mistakes.
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')
Copy link

Copilot AI Jan 5, 2026

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).

Suggested change
query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval')
query_params = filter.to_h.slice(:start_ts, :end_ts, :period_interval)

Copilot uses AI. Check for mistakes.
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')
Copy link

Copilot AI Jan 5, 2026

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).

Suggested change
query_params = filter.to_h.slice('start_ts', 'end_ts', 'period_interval')
query_params = filter.to_h.slice(:start_ts, :end_ts, :period_interval)

Copilot uses AI. Check for mistakes.
let(:base_url) { Rubyists::Kalshi.config.base_url }

describe '#event_candlesticks' do
it 'returns a EventCandlesticks instance' do
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
it 'returns a EventCandlesticks instance' do
it 'returns an EventCandlesticks instance' do

Copilot uses AI. Check for mistakes.
Comment on lines +8 to +14
def event_candlesticks
EventCandlesticks.new(client)
end

def forecast_percentile_history
ForecastPercentileHistory.new(client)
end
Copy link

Copilot AI Jan 5, 2026

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).

Copilot uses AI. Check for mistakes.
@bougyman bougyman merged commit a9fcb72 into main Jan 5, 2026
5 of 6 checks passed
@bougyman bougyman deleted the add-events branch January 5, 2026 19:24
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.

2 participants