Skip to content

Commit

Permalink
Add sort argument to get_markets (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Feb 21, 2024
1 parent f52a2d2 commit bc88190
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion prediction_market_agent_tooling/benchmark/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ class MarketFilter(str, Enum):
resolved = "resolved"


class MarketSort(str, Enum):
liquidity = "liquidity"
newest = "newest"


class MarketResolution(str, Enum):
YES = "yes"
NO = "no"
Expand Down Expand Up @@ -305,13 +310,19 @@ def get_markets(
number: int,
source: MarketSource,
filter_: MarketFilter = MarketFilter.open,
sort: MarketSort | None = None,
excluded_questions: set[str] | None = None,
) -> t.List[Market]:
if source == MarketSource.MANIFOLD:
return get_manifold_markets_paged(
number=number, excluded_questions=excluded_questions, filter_=filter_.value
number=number,
excluded_questions=excluded_questions,
filter_=filter_.value,
sort=(sort or MarketSort.liquidity).value,
)
elif source == MarketSource.POLYMARKET:
if sort is not None:
raise ValueError(f"Polymarket doesn't support sorting.")
return get_polymarket_markets(
limit=number,
excluded_questions=excluded_questions,
Expand Down

0 comments on commit bc88190

Please sign in to comment.