Skip to content

Commit

Permalink
Small fixes and improvements (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored May 29, 2024
1 parent fa7e7e0 commit ceb4304
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
4 changes: 2 additions & 2 deletions prediction_market_agent_tooling/deploy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion prediction_market_agent_tooling/markets/omen/omen.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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(
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.31.0"
version = "0.32.0"
description = "Tools to benchmark, deploy and monitor prediction market agents."
authors = ["Gnosis"]
readme = "README.md"
Expand Down

0 comments on commit ceb4304

Please sign in to comment.