Skip to content

Conversation

@DeirhX
Copy link
Contributor

@DeirhX DeirhX commented Nov 2, 2025

Pull Request

NautilusTrader prioritizes correctness and reliability, please follow existing patterns for validation and testing.

  • I have reviewed the CONTRIBUTING.md and followed the established practices

Summary

Watching a large number (1000+) instruments currently gives us two options for initialisation:
a) fetch every instrument separately (1000+ API calls, too slow)
b) sequentially iterate over all historic markets (faster, however, there are currently 160K of them and growing)
None of these options are particularly efficient and future-proof. This PR introduces a third option - use the Gamma API to fetch the market list, which supports server-side filtering, and we can query only for active markets.

Note, however, that the Gamma API is different and has some caveats:

Related Issues/PRs

Together with #3140 and (coming soon) enables Nautilus to work on thousands of polymarket subscriptions

Type of change

  • Bug fix (non-breaking)
  • New feature (non-breaking)
  • Improvement (non-breaking)
  • Breaking change (impacts existing behavior)
  • Documentation update
  • Maintenance / chore

Breaking change details (if applicable)

None

Testing

I verified that the output is parsed into the fields returned by the CLOB API if we have them. This alternative is activated using use_gamma_markets = True, so it should not affect existing behaviour. I leave it up to you to change the defaults if this proves to be both useful and safe (one disadvantage I know of - Gamma API doesn't report on fees, however, we know they are zero for now. Unless they become market-dependent, we can get away with updating a constant here).

See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
See release notes.
@CLAassistant
Copy link

CLAassistant commented Nov 2, 2025

CLA assistant check
All committers have signed the CLA.

@odobias
Copy link
Contributor

odobias commented Nov 3, 2025

I see the assertion comparison is probably not by value, will fix it tomorrow.

@cjdsellers cjdsellers changed the title Adds an alternate, high-throughput way of fetching Polymarket market details Add Polymarket Gamma API support for instrument loading Nov 3, 2025
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this @DeirhX 🙏

@DeirhX
Copy link
Contributor Author

DeirhX commented Nov 6, 2025

Thanks for the suggestions, hopefully I addressed them.

@cjdsellers cjdsellers merged commit 31ecce8 into nautechsystems:develop Nov 6, 2025
17 checks passed
@cjdsellers
Copy link
Member

@DeirhX I just followed up with this to filter specific tokens.

Let me know if it causes and issues for you and I'll fix it up.

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.

4 participants