From ceb4304149e94c6f284e1cea38273d0f53dfe37f Mon Sep 17 00:00:00 2001 From: Peter Jung Date: Wed, 29 May 2024 12:39:51 +0200 Subject: [PATCH] Small fixes and improvements (#259) --- prediction_market_agent_tooling/deploy/agent.py | 4 ++-- .../markets/omen/omen.py | 2 +- .../markets/omen/omen_subgraph_handler.py | 15 ++++++++++++++- pyproject.toml | 2 +- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/prediction_market_agent_tooling/deploy/agent.py b/prediction_market_agent_tooling/deploy/agent.py index c2893f2a..14b114a3 100644 --- a/prediction_market_agent_tooling/deploy/agent.py +++ b/prediction_market_agent_tooling/deploy/agent.py @@ -273,11 +273,11 @@ def process_bets(self, market_type: MarketType) -> None: for market in markets: result = self.answer_binary_market(market) if result is None: - logger.debug(f"Skipping market {market} as no answer was provided") + logger.info(f"Skipping market {market} as no answer was provided") continue if self.place_bet: amount = self.calculate_bet_amount(result, market) - logger.debug( + logger.info( f"Placing bet on {market} with result {result} and amount {amount}" ) market.place_bet( diff --git a/prediction_market_agent_tooling/markets/omen/omen.py b/prediction_market_agent_tooling/markets/omen/omen.py index 60c4a929..8a8d2770 100644 --- a/prediction_market_agent_tooling/markets/omen/omen.py +++ b/prediction_market_agent_tooling/markets/omen/omen.py @@ -156,7 +156,7 @@ def place_bet( ) def sell_tokens( - self, outcome: bool, amount: TokenAmount, auto_withdraw: bool = True + self, outcome: bool, amount: TokenAmount, auto_withdraw: bool = False ) -> None: if not self.can_be_traded(): raise ValueError( diff --git a/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py b/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py index afd1e35b..61bcf3cb 100644 --- a/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +++ b/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py @@ -205,8 +205,9 @@ def _build_where_statements( finalized_before ) + # `excluded_question_titles` can not be an empty list, otherwise the API bugs out and returns nothing. excluded_question_titles = [""] - if excluded_questions is not None: + if excluded_questions: excluded_question_titles = [i for i in excluded_questions] where_stms["question_"]["title_not_in"] = excluded_question_titles @@ -439,6 +440,8 @@ def get_trades( market_id: t.Optional[ChecksumAddress] = None, filter_by_answer_finalized_not_null: bool = False, type_: t.Literal["Buy", "Sell"] | None = None, + market_opening_after: datetime | None = None, + collateral_amount_more_than: Wei | None = None, ) -> list[OmenBet]: if not end_time: end_time = utcnow() @@ -457,6 +460,12 @@ def get_trades( where_stms.append(trade.fpmm == market_id.lower()) if filter_by_answer_finalized_not_null: where_stms.append(trade.fpmm.answerFinalizedTimestamp != None) + if market_opening_after is not None: + where_stms.append( + trade.fpmm.openingTimestamp > to_int_timestamp(market_opening_after) + ) + if collateral_amount_more_than is not None: + where_stms.append(trade.collateralAmount > collateral_amount_more_than) trades = self.trades_subgraph.Query.fpmmTrades( first=sys.maxsize, where=where_stms @@ -473,6 +482,8 @@ def get_bets( end_time: t.Optional[datetime] = None, market_id: t.Optional[ChecksumAddress] = None, filter_by_answer_finalized_not_null: bool = False, + market_opening_after: datetime | None = None, + collateral_amount_more_than: Wei | None = None, ) -> list[OmenBet]: return self.get_trades( better_address=better_address, @@ -481,6 +492,8 @@ def get_bets( market_id=market_id, filter_by_answer_finalized_not_null=filter_by_answer_finalized_not_null, type_="Buy", # We consider `bet` to be only the `Buy` trade types. + market_opening_after=market_opening_after, + collateral_amount_more_than=collateral_amount_more_than, ) def get_resolved_bets( diff --git a/pyproject.toml b/pyproject.toml index fa74a217..e9ea9c25 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "prediction-market-agent-tooling" -version = "0.31.0" +version = "0.32.0" description = "Tools to benchmark, deploy and monitor prediction market agents." authors = ["Gnosis"] readme = "README.md"