Skip to content

Commit

Permalink
Surface 'getting market by id' to AgentMarket (#178)
Browse files Browse the repository at this point in the history
* Surface 'getting market by id' to AgentMarket

* Bump python version
---------

Co-authored-by: Peter Jung <[email protected]>
  • Loading branch information
evangriffiths and kongzii authored Apr 10, 2024
1 parent 6e86e54 commit 69cb306
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions prediction_market_agent_tooling/markets/agent_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ def get_binary_markets(
) -> t.Sequence["AgentMarket"]:
raise NotImplementedError("Subclasses must implement this method")

@staticmethod
def get_binary_market(id: str) -> "AgentMarket":
raise NotImplementedError("Subclasses must implement this method")

def is_resolved(self) -> bool:
return self.resolution is not None

Expand Down
8 changes: 8 additions & 0 deletions prediction_market_agent_tooling/markets/omen/omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,14 @@ def get_binary_markets(
)
]

@staticmethod
def get_binary_market(id: str) -> "OmenAgentMarket":
return OmenAgentMarket.from_data_model(
OmenSubgraphHandler().get_omen_market_by_market_id(
market_id=HexAddress(HexStr(id))
)
)

def get_contract(self) -> OmenFixedProductMarketMakerContract:
return OmenFixedProductMarketMakerContract(
address=self.market_maker_contract_address_checksummed
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "prediction-market-agent-tooling"
version = "0.10.0"
version = "0.11.0"
description = "Tools to benchmark, deploy and monitor prediction market agents."
authors = ["Gnosis"]
readme = "README.md"
Expand Down
6 changes: 6 additions & 0 deletions tests/markets/omen/test_omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,9 @@ def test_market_liquidity() -> None:
assert (
market.get_liquidity_in_xdai() > 0
), "Market liquidity should be greater than 0."


def test_get_binary_market() -> None:
id = "0x0020d13c89140b47e10db54cbd53852b90bc1391"
market = OmenAgentMarket.get_binary_market(id)
assert market.id == id

0 comments on commit 69cb306

Please sign in to comment.