Skip to content

fix: use correct Gamma API parameter for filtering open markets#3

Open
pennycott wants to merge 1 commit intocaiovicentino:mainfrom
pennycott:fix/gamma-api-market-filter-parameter
Open

fix: use correct Gamma API parameter for filtering open markets#3
pennycott wants to merge 1 commit intocaiovicentino:mainfrom
pennycott:fix/gamma-api-market-filter-parameter

Conversation

@pennycott
Copy link

📋 Description

The Gamma API requires closed: "false" to filter for open/active markets, not active: "true" which was being used. This caused all market discovery tools (trending, categories, featured, etc.) to return only closed markets from 2020 instead of current active markets.

🎯 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📖 Documentation update
  • 🧪 Test improvements
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement

🔗 Related Issues

Markets discovery tools return closed markets from 2020 instead of current open markets when using demo mode (or any mode).

🧪 Testing

Test Configuration

  • Python Version: 3.14
  • OS: macOS
  • Branch: fix/gamma-api-market-filter-parameter

Tests Performed

  • All existing tests pass (pytest)
  • Added new tests for new functionality
  • Tested manually with real Polymarket API
  • Verified safety limits still work
  • Tested with Claude Desktop integration

Test Results

tests/test_market_tools.py::TestMarketDiscovery::test_search_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_trending_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_filter_markets_by_category PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_featured_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_closing_soon_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_sports_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_crypto_markets PASSED
tests/test_market_tools.py::TestMarketDiscovery::test_get_event_markets PASSED
======================== 8 passed, 1 warning in 12.01s =========================

📸 Screenshots / Examples

Before fix - returns 2020 closed markets:

Markets from 2020...

After fix - returns current open markets:

# Trending markets now correctly return current 2025 markets:
- "Russia x Ukraine ceasefire in 2025?" (ends: 2025-12-31)
- "Will Bitcoin reach $1,000,000 by December 31, 2025?" (ends: 2025-12-31)
- "Will Bitcoin reach $200,000 by December 31, 2025?" (ends: 2025-12-31)

✅ Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published
  • I have checked my code and corrected any misspellings
  • I have updated the CHANGELOG.md file

🔒 Security

  • This PR does not introduce security vulnerabilities
  • I have verified no credentials are exposed
  • Safety limits are still enforced
  • Input validation is adequate

⚠️ Breaking Changes

Does this PR introduce breaking changes?

  • Yes (describe below)
  • No

💬 Additional Notes

Changed all 6 affected functions in src/polymarket_mcp/tools/market_discovery.py:

  • get_trending_markets() - line 137
  • filter_markets_by_category() - line 185
  • get_featured_markets() - line 249
  • get_closing_soon_markets() - line 285
  • get_sports_markets() - line 335
  • get_crypto_markets() - line 374

The fix simply changes the API parameter from {"active": "true"} to {"closed": "false"} which is what the Gamma API actually expects. This can be verified in test_real_data.py which already uses the correct parameter.

🤖 Generated with Claude Code

@pennycott pennycott force-pushed the fix/gamma-api-market-filter-parameter branch from df2a93d to 00ed3d3 Compare December 11, 2025 20:06
The Gamma API requires `closed: "false"` to filter for open/active markets,
not `active: "true"` which was being used. This caused all market discovery
tools to return only closed markets from 2020 instead of current active markets.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@pennycott pennycott force-pushed the fix/gamma-api-market-filter-parameter branch from 00ed3d3 to fa71420 Compare December 11, 2025 20:07
@baalimago
Copy link

This works! I ran into the same issue and re-did the changes on a local version. Now it shows recent markets.

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