prediction-market-agent-tooling 0.47.0__py3-none-any.whl → 0.47.1__py3-none-any.whl

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.
@@ -216,6 +216,19 @@ class DeployableTraderAgent(DeployableAgent):
216
216
  def have_bet_on_market_since(self, market: AgentMarket, since: timedelta) -> bool:
217
217
  return have_bet_on_market_since(keys=APIKeys(), market=market, since=since)
218
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
+
219
232
  def pick_markets(
220
233
  self, market_type: MarketType, markets: t.Sequence[AgentMarket]
221
234
  ) -> t.Sequence[AgentMarket]:
@@ -280,15 +293,7 @@ class DeployableTraderAgent(DeployableAgent):
280
293
  if market_type == MarketType.OMEN:
281
294
  # Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
282
295
  redeem_from_all_user_positions(api_keys)
283
- # Check if we have enough of balance to operate.
284
- if self.min_required_balance_to_operate is not None:
285
- if not is_minimum_required_balance(
286
- api_keys.public_key,
287
- min_required_balance=self.min_required_balance_to_operate,
288
- ):
289
- raise OutOfFundsError(
290
- f"Minimum required balance {self.min_required_balance_to_operate} is not met."
291
- )
296
+ self.check_min_required_balance_to_operate(market_type)
292
297
  # Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
293
298
  if self.min_balance_to_keep_in_native_currency is not None:
294
299
  withdraw_wxdai_to_xdai_to_keep_balance(
@@ -304,6 +309,8 @@ class DeployableTraderAgent(DeployableAgent):
304
309
  available_markets = self.get_markets(market_type)
305
310
  markets = self.pick_markets(market_type, available_markets)
306
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)
307
314
  result = self.answer_binary_market(market)
308
315
  if result is None:
309
316
  logger.info(f"Skipping market {market} as no answer was provided")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.47.0
3
+ Version: 0.47.1
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.12
@@ -15,7 +15,7 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3Ukktb
15
15
  prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
16
16
  prediction_market_agent_tooling/benchmark/utils.py,sha256=iS1BzyXcCMfMm1Rx--1QCH0pHvBTblTndcDQFbTUJ2s,2897
17
17
  prediction_market_agent_tooling/config.py,sha256=3j1iMiJWntSkqQv5HllJgihgqf9I2_0e0LPncVFRi7g,5260
18
- prediction_market_agent_tooling/deploy/agent.py,sha256=qaFbPaiVlxOV_drXUasYwuJgoA37wyMoTRA5MRPDarg,11672
18
+ prediction_market_agent_tooling/deploy/agent.py,sha256=Bj4L-zgUprLqcCENGZR205GaK52lu2iQwFspJDN0jgY,12017
19
19
  prediction_market_agent_tooling/deploy/agent_example.py,sha256=V_yakxDvG3WZWRsQq6-b2ZLA8pPPnf0Jrw8iGkGZGG8,1019
20
20
  prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
21
21
  prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
@@ -75,8 +75,8 @@ prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0r
75
75
  prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
76
76
  prediction_market_agent_tooling/tools/utils.py,sha256=JE9YWtPPhnTgLiOyGAZDNG5K8nCwUY9IZEuAlm9UcxA,6611
77
77
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=nKRHmdLnWSKd3wpo-cysXGvhhrJ2Yf69sN2FFQfSt6s,10578
78
- prediction_market_agent_tooling-0.47.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
79
- prediction_market_agent_tooling-0.47.0.dist-info/METADATA,sha256=y9NRHOcSEBx1b32DwPINwQQ1lqiaDoappIIayDz1rOI,7634
80
- prediction_market_agent_tooling-0.47.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
81
- prediction_market_agent_tooling-0.47.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
82
- prediction_market_agent_tooling-0.47.0.dist-info/RECORD,,
78
+ prediction_market_agent_tooling-0.47.1.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
79
+ prediction_market_agent_tooling-0.47.1.dist-info/METADATA,sha256=jgYABVYq6hJlFc-OorHN0sGi74IDD34xqhthepX26vM,7634
80
+ prediction_market_agent_tooling-0.47.1.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
81
+ prediction_market_agent_tooling-0.47.1.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
82
+ prediction_market_agent_tooling-0.47.1.dist-info/RECORD,,