Skip to content

PolymarketInstrumentProvider filtering for markets #3133

@MisterMM23

Description

@MisterMM23

Bug Report

Confirmation

  • I’ve re-read the relevant sections of the documentation.
  • I’ve searched existing issues and discussions to avoid duplicates.
  • I’ve reviewed or skimmed the source code (or examples) to confirm the behavior is not by design.
  • I’ve tested this issue using a recent development wheel (dev develop or a nightly) and can still reproduce it.

Expected Behavior

In PolymarketInstrumentProvider._load_markets(), when filtering for active markets, one would expect markets to be loaded that are truly active, as per the implicit definition in the polymarket gamma API documentation, namely markets that are not "closed"

Actual Behavior

However, the function filters for markets whose "active" keyword is set to "true". I'm not sure what this keyword exactly represents, but I believe it just means that one can trade on the market. I suppose the distinction between closed and active exists for when the closing of a market gets successfully disputed

Steps to Reproduce the Problem

  1. Create a PolyMarketInstrumentProvider instance
  2. Run instrument_provider.load_all_async(filters={'is_active' : True})
  3. Count the elements in instrument_provider.get_all().keys()
  4. Compare this to running instrument_provider.load_all_async(), without filters

Suggested Fix

In nautilus_trader/adapters/polymarket/providers.py, line 9, starts the following snippet:

active = market_info["active"]
if filter_is_active and not active:
  continue

Change to this:

closed = market_info["closed"]
if filter_is_active and closed:
    continue

A fork was created with exactly this fix, see branch fix/polymarket-filtering

Specifications

  • OS platform: Linux
  • Python version: latest
  • nautilus_trader version: latest commit on devlopment branch

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions