Skip to content

Conversation

@bougyman
Copy link
Member

@bougyman bougyman commented Jan 5, 2026

  • doc: updated Readme with a more real-world filter use case
  • feat: adds all market/ endpoints

@bougyman bougyman requested review from Copilot January 5, 2026 00:33
@bougyman bougyman merged commit b7bd5a7 into main Jan 5, 2026
10 checks passed
@bougyman bougyman deleted the fix-status-parameters branch January 5, 2026 00:35
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 implements comprehensive support for all Kalshi market endpoints, providing a complete interface for market data operations through a new Market::Client wrapper.

  • Adds Market::Client wrapper to organize market-related endpoints
  • Implements four new market endpoints: Markets, Orderbook, Trades, and Candlesticks
  • Updates README with practical usage examples replacing previous placeholder documentation

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lib/kalshi/client.rb Adds memoized market accessor method returning Market::Client
lib/kalshi/market/client.rb New Market::Client wrapper providing memoized access to all market endpoints
lib/kalshi/market/markets.rb Implements Markets endpoint with list and fetch methods, includes Filter contract
lib/kalshi/market/orderbook.rb Implements Orderbook endpoint with optional depth parameter
lib/kalshi/market/trades.rb Implements Trades endpoint with list method and Filter contract
lib/kalshi/market/candlesticks.rb Implements Candlesticks endpoint with fetch and batch methods
test/kalshi/client_test.rb Adds test verifying market method returns correct instance
test/kalshi/market/client_test.rb Comprehensive tests for all Market::Client accessor methods with memoization verification
test/kalshi/market/markets_test.rb Tests for Markets list and fetch methods with filters
test/kalshi/market/orderbook_test.rb Tests for Orderbook fetch with and without depth parameter
test/kalshi/market/trades_test.rb Tests for Trades list method with filters
test/kalshi/market/candlesticks_test.rb Tests for Candlesticks fetch and batch methods, including array and string ticker handling
Readme.adoc Updates documentation from placeholder to working examples using client.market namespace

Comment on lines +10 to +28
describe '#list' do
it 'fetches the markets list' do
stub_request(:get, "#{base_url}/markets")
.to_return(status: 200, body: '{"markets": []}', headers: { 'Content-Type' => 'application/json' })

response = markets.list

assert_equal({ markets: [] }, response)
end

it 'fetches the markets list with filters' do
stub_request(:get, "#{base_url}/markets")
.with(query: { status: 'open' })
.to_return(status: 200, body: '{"markets": []}', headers: { 'Content-Type' => 'application/json' })

response = markets.list(status: 'open')

assert_equal({ markets: [] }, response)
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.

Consider adding validation tests for the Filter contract. Other similar endpoints like SeriesList include tests for invalid parameters and invalid values to ensure the contract validation is working correctly. This would improve test coverage for error cases.

Copilot uses AI. Check for mistakes.
Comment on lines +10 to +28
describe '#list' do
it 'fetches the trades list' do
stub_request(:get, "#{base_url}/markets/trades")
.to_return(status: 200, body: '{"trades": []}', headers: { 'Content-Type' => 'application/json' })

response = trades.list

assert_equal({ trades: [] }, response)
end

it 'fetches the trades list with filters' do
stub_request(:get, "#{base_url}/markets/trades")
.with(query: { ticker: 'KX-MARKET' })
.to_return(status: 200, body: '{"trades": []}', headers: { 'Content-Type' => 'application/json' })

response = trades.list(ticker: 'KX-MARKET')

assert_equal({ trades: [] }, response)
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.

Consider adding validation tests for the Filter contract. Other similar endpoints like SeriesList include tests for invalid parameters and invalid values to ensure the contract validation is working correctly. This would improve test coverage for error cases.

Copilot uses AI. Check for mistakes.
Comment on lines +21 to +27
describe '#market' do
it 'returns a Market::Client instance' do
client = Rubyists::Kalshi::Client.new

assert_instance_of Rubyists::Kalshi::Market::Client, client.market
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.

Consider adding a test to verify that the market method is memoized, similar to the memoization tests for series_list, series, markets, orderbook, trades, and candlesticks in the Market::Client tests. This ensures consistent caching behavior.

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +41
describe '#fetch' do
it 'fetches a specific market by ticker' do
ticker = 'KX-MARKET'
stub_request(:get, "#{base_url}/markets/#{ticker}")
.to_return(status: 200, body: '{"market": {}}', headers: { 'Content-Type' => 'application/json' })

response = markets.fetch(ticker)

assert_equal({ market: {} }, response)
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.

Consider adding a test for the class-level list method (Markets.list), similar to the test in SeriesList. The Listable module provides this functionality, and it should be tested for consistency.

Copilot uses AI. Check for mistakes.
Comment on lines +20 to +29
it 'fetches the trades list with filters' do
stub_request(:get, "#{base_url}/markets/trades")
.with(query: { ticker: 'KX-MARKET' })
.to_return(status: 200, body: '{"trades": []}', headers: { 'Content-Type' => 'application/json' })

response = trades.list(ticker: 'KX-MARKET')

assert_equal({ trades: [] }, response)
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.

Consider adding a test for the class-level list method (Trades.list), similar to the test in SeriesList. The Listable module provides this functionality, and it should be tested for consistency.

Copilot uses AI. Check for mistakes.
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