Skip to content

Commit

Permalink
Add description to agent market (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Jul 12, 2024
1 parent 266b0bd commit 3cb9487
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
1 change: 1 addition & 0 deletions prediction_market_agent_tooling/markets/agent_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AgentMarket(BaseModel):

id: str
question: str
description: str | None
outcomes: list[str]
resolution: Resolution | None
created_time: datetime | None
Expand Down
8 changes: 5 additions & 3 deletions prediction_market_agent_tooling/markets/manifold/manifold.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
from prediction_market_agent_tooling.markets.manifold.api import (
get_authenticated_user,
get_manifold_binary_markets,
get_manifold_market,
place_bet,
)
from prediction_market_agent_tooling.markets.manifold.data_models import (
MANIFOLD_BASE_URL,
ManifoldMarket,
FullManifoldMarket,
)
from prediction_market_agent_tooling.tools.betting_strategies.minimum_bet_to_win import (
minimum_bet_to_win,
Expand Down Expand Up @@ -58,10 +59,11 @@ def place_bet(self, outcome: bool, amount: BetAmount) -> None:
)

@staticmethod
def from_data_model(model: ManifoldMarket) -> "ManifoldAgentMarket":
def from_data_model(model: FullManifoldMarket) -> "ManifoldAgentMarket":
return ManifoldAgentMarket(
id=model.id,
question=model.question,
description=model.textDescription,
outcomes=model.outcomes,
resolution=model.resolution,
created_time=model.createdTime,
Expand Down Expand Up @@ -100,7 +102,7 @@ def get_binary_markets(
raise ValueError(f"Unknown filter_by: {filter_by}")

return [
ManifoldAgentMarket.from_data_model(m)
ManifoldAgentMarket.from_data_model(get_manifold_market(m.id))
for m in get_manifold_binary_markets(
limit=limit,
sort=sort,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class MetaculusAgentMarket(AgentMarket):

have_predicted: bool
base_url: t.ClassVar[str] = METACULUS_API_BASE_URL
description: str | None = (
None # Metaculus markets don't have a description, so just default to None.
)

@staticmethod
def from_data_model(model: MetaculusQuestion) -> "MetaculusAgentMarket":
Expand Down
3 changes: 3 additions & 0 deletions prediction_market_agent_tooling/markets/omen/omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class OmenAgentMarket(AgentMarket):
)

_binary_market_p_yes_history: list[Probability] | None = None
description: str | None = (
None # Omen markets don't have a description, so just default to None.
)

@property
def yes_index(self) -> int:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def from_data_model(model: PolymarketMarketWithPrices) -> "PolymarketAgentMarket
return PolymarketAgentMarket(
id=model.id,
question=model.question,
description=model.description,
outcomes=[x.outcome for x in model.tokens],
resolution=model.resolution,
current_p_yes=model.p_yes,
Expand Down
1 change: 1 addition & 0 deletions tests/markets/test_betting_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def test_minimum_bet_to_win_manifold(
min_bet = ManifoldAgentMarket(
id="id",
question="question",
description=None,
outcomes=["Yes", "No"],
current_p_yes=market_p_yes,
created_time=utcnow() - timedelta(days=1),
Expand Down
8 changes: 8 additions & 0 deletions tests/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_benchmark_run(
benchmarker = bm.Benchmarker(
markets=[
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand Down Expand Up @@ -112,6 +113,7 @@ def test_benchmarker_cache(dummy_agent: DummyAgent) -> None:
cache_path = f"{tmpdir}/cache.json"
markets = [
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand Down Expand Up @@ -179,6 +181,7 @@ def test_benchmarker_cache(dummy_agent: DummyAgent) -> None:
def test_benchmarker_cancelled_markets() -> None:
markets = [
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand All @@ -204,6 +207,7 @@ def test_benchmarker_cancelled_markets() -> None:
def test_market_probable_resolution() -> None:
with pytest.raises(ValueError) as e:
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand All @@ -217,6 +221,7 @@ def test_market_probable_resolution() -> None:
assert "Unknown resolution" in str(e)
assert (
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand All @@ -231,6 +236,7 @@ def test_market_probable_resolution() -> None:
)
assert (
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand All @@ -245,6 +251,7 @@ def test_market_probable_resolution() -> None:
)
assert (
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand All @@ -259,6 +266,7 @@ def test_market_probable_resolution() -> None:
)
assert (
PolymarketAgentMarket(
description=None,
id="1",
volume=None,
url="url",
Expand Down

0 comments on commit 3cb9487

Please sign in to comment.