prediction-market-agent-tooling 0.46.0__tar.gz → 0.47.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/agent.py +30 -4
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/omen.py +14 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/pyproject.toml +1 -1
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/README.md +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/cache.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/google.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.46.0 → prediction_market_agent_tooling-0.47.1}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -22,7 +22,7 @@ from prediction_market_agent_tooling.deploy.gcp.utils import (
|
|
22
22
|
gcp_function_is_active,
|
23
23
|
gcp_resolve_api_keys_secrets,
|
24
24
|
)
|
25
|
-
from prediction_market_agent_tooling.gtypes import Probability, xdai_type
|
25
|
+
from prediction_market_agent_tooling.gtypes import Probability, xDai, xdai_type
|
26
26
|
from prediction_market_agent_tooling.loggers import logger
|
27
27
|
from prediction_market_agent_tooling.markets.agent_market import (
|
28
28
|
AgentMarket,
|
@@ -35,6 +35,7 @@ from prediction_market_agent_tooling.markets.markets import (
|
|
35
35
|
have_bet_on_market_since,
|
36
36
|
)
|
37
37
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
38
|
+
is_minimum_required_balance,
|
38
39
|
redeem_from_all_user_positions,
|
39
40
|
withdraw_wxdai_to_xdai_to_keep_balance,
|
40
41
|
)
|
@@ -73,6 +74,10 @@ def to_boolean_outcome(value: str | bool) -> bool:
|
|
73
74
|
Decision = Annotated[bool, BeforeValidator(to_boolean_outcome)]
|
74
75
|
|
75
76
|
|
77
|
+
class OutOfFundsError(ValueError):
|
78
|
+
pass
|
79
|
+
|
80
|
+
|
76
81
|
class Answer(BaseModel):
|
77
82
|
decision: Decision # Warning: p_yes > 0.5 doesn't necessarily mean decision is True! For example, if our p_yes is 55%, but market's p_yes is 80%, then it might be profitable to bet on False.
|
78
83
|
p_yes: Probability
|
@@ -201,6 +206,8 @@ def {entrypoint_function_name}(request) -> str:
|
|
201
206
|
|
202
207
|
class DeployableTraderAgent(DeployableAgent):
|
203
208
|
bet_on_n_markets_per_run: int = 1
|
209
|
+
min_required_balance_to_operate: xDai | None = xdai_type(1)
|
210
|
+
min_balance_to_keep_in_native_currency: xDai | None = xdai_type(0.1)
|
204
211
|
|
205
212
|
def __init__(self, place_bet: bool = True) -> None:
|
206
213
|
super().__init__()
|
@@ -209,6 +216,19 @@ class DeployableTraderAgent(DeployableAgent):
|
|
209
216
|
def have_bet_on_market_since(self, market: AgentMarket, since: timedelta) -> bool:
|
210
217
|
return have_bet_on_market_since(keys=APIKeys(), market=market, since=since)
|
211
218
|
|
219
|
+
def check_min_required_balance_to_operate(self, market_type: MarketType) -> None:
|
220
|
+
api_keys = APIKeys()
|
221
|
+
if self.min_required_balance_to_operate is None:
|
222
|
+
return
|
223
|
+
if market_type == MarketType.OMEN and not is_minimum_required_balance(
|
224
|
+
api_keys.public_key,
|
225
|
+
min_required_balance=self.min_required_balance_to_operate,
|
226
|
+
):
|
227
|
+
raise OutOfFundsError(
|
228
|
+
f"Minimum required balance {self.min_required_balance_to_operate} "
|
229
|
+
f"for agent with address {api_keys.public_key} is not met."
|
230
|
+
)
|
231
|
+
|
212
232
|
def pick_markets(
|
213
233
|
self, market_type: MarketType, markets: t.Sequence[AgentMarket]
|
214
234
|
) -> t.Sequence[AgentMarket]:
|
@@ -273,10 +293,14 @@ class DeployableTraderAgent(DeployableAgent):
|
|
273
293
|
if market_type == MarketType.OMEN:
|
274
294
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
275
295
|
redeem_from_all_user_positions(api_keys)
|
296
|
+
self.check_min_required_balance_to_operate(market_type)
|
276
297
|
# Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
|
277
|
-
|
278
|
-
|
279
|
-
|
298
|
+
if self.min_balance_to_keep_in_native_currency is not None:
|
299
|
+
withdraw_wxdai_to_xdai_to_keep_balance(
|
300
|
+
api_keys,
|
301
|
+
min_required_balance=self.min_balance_to_keep_in_native_currency,
|
302
|
+
withdraw_multiplier=2,
|
303
|
+
)
|
280
304
|
|
281
305
|
def process_bets(self, market_type: MarketType) -> None:
|
282
306
|
"""
|
@@ -285,6 +309,8 @@ class DeployableTraderAgent(DeployableAgent):
|
|
285
309
|
available_markets = self.get_markets(market_type)
|
286
310
|
markets = self.pick_markets(market_type, available_markets)
|
287
311
|
for market in markets:
|
312
|
+
# We need to check it again before each market bet, as the balance might have changed.
|
313
|
+
self.check_min_required_balance_to_operate(market_type)
|
288
314
|
result = self.answer_binary_market(market)
|
289
315
|
if result is None:
|
290
316
|
logger.info(f"Skipping market {market} as no answer was provided")
|
@@ -1043,6 +1043,20 @@ def get_binary_market_p_yes_history(market: OmenAgentMarket) -> list[Probability
|
|
1043
1043
|
return history
|
1044
1044
|
|
1045
1045
|
|
1046
|
+
def is_minimum_required_balance(
|
1047
|
+
address: ChecksumAddress,
|
1048
|
+
min_required_balance: xDai,
|
1049
|
+
web3: Web3 | None = None,
|
1050
|
+
) -> bool:
|
1051
|
+
"""
|
1052
|
+
Checks if the total balance of xDai and wxDai in the wallet is above the minimum required balance.
|
1053
|
+
"""
|
1054
|
+
current_balances = get_balances(address, web3)
|
1055
|
+
# xDai and wxDai have equal value and can be exchanged for almost no cost, so we can sum them up.
|
1056
|
+
total_balance = current_balances.xdai + current_balances.wxdai
|
1057
|
+
return total_balance >= min_required_balance
|
1058
|
+
|
1059
|
+
|
1046
1060
|
def withdraw_wxdai_to_xdai_to_keep_balance(
|
1047
1061
|
api_keys: APIKeys,
|
1048
1062
|
min_required_balance: xDai,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|