prediction-market-agent-tooling 0.66.2__py3-none-any.whl → 0.66.3__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.
@@ -40,6 +40,9 @@ class GuaranteedLossError(RuntimeError):
40
40
 
41
41
 
42
42
  class BettingStrategy(ABC):
43
+ def __init__(self, take_profit: bool = True) -> None:
44
+ self.take_profit = take_profit
45
+
43
46
  @abstractmethod
44
47
  def calculate_trades(
45
48
  self,
@@ -209,10 +212,22 @@ class BettingStrategy(ABC):
209
212
  )
210
213
 
211
214
  diff_amount = target_amount - existing_amount
215
+
212
216
  if diff_amount == 0:
213
217
  continue
214
218
 
215
219
  trade_type = TradeType.SELL if diff_amount < 0 else TradeType.BUY
220
+
221
+ # We work with positions, so imagine following scenario: Agent invested $10 when probs were 50:50,
222
+ # now the probs are 99:1 and his initial $10 is worth $100.
223
+ # If `take_profit` is set to False, agent won't sell the $90 to get back to the $10 position.
224
+ if (
225
+ not self.take_profit
226
+ and target_amount > 0
227
+ and trade_type == TradeType.SELL
228
+ ):
229
+ continue
230
+
216
231
  trade = Trade(
217
232
  amount=abs(diff_amount),
218
233
  outcome=outcome,
@@ -231,7 +246,8 @@ class BettingStrategy(ABC):
231
246
 
232
247
 
233
248
  class MultiCategoricalMaxAccuracyBettingStrategy(BettingStrategy):
234
- def __init__(self, max_position_amount: USD):
249
+ def __init__(self, max_position_amount: USD, take_profit: bool = True):
250
+ super().__init__(take_profit=take_profit)
235
251
  self.max_position_amount = max_position_amount
236
252
 
237
253
  @property
@@ -336,7 +352,13 @@ class MaxExpectedValueBettingStrategy(MultiCategoricalMaxAccuracyBettingStrategy
336
352
 
337
353
 
338
354
  class KellyBettingStrategy(BettingStrategy):
339
- def __init__(self, max_position_amount: USD, max_price_impact: float | None = None):
355
+ def __init__(
356
+ self,
357
+ max_position_amount: USD,
358
+ max_price_impact: float | None = None,
359
+ take_profit: bool = True,
360
+ ):
361
+ super().__init__(take_profit=take_profit)
340
362
  self.max_position_amount = max_position_amount
341
363
  self.max_price_impact = max_price_impact
342
364
 
@@ -492,7 +514,12 @@ class KellyBettingStrategy(BettingStrategy):
492
514
 
493
515
 
494
516
  class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
495
- def __init__(self, max_position_amount: USD):
517
+ def __init__(
518
+ self,
519
+ max_position_amount: USD,
520
+ take_profit: bool = True,
521
+ ):
522
+ super().__init__(take_profit)
496
523
  self.max_position_amount = max_position_amount
497
524
 
498
525
  @property
@@ -53,7 +53,7 @@ from prediction_market_agent_tooling.tools.web3_utils import (
53
53
  unwrap_generic_value,
54
54
  )
55
55
 
56
- SAFE_COLLATERAL_TOKENS = (
56
+ SAFE_COLLATERAL_TOKENS = [
57
57
  WrappedxDaiContract(),
58
58
  sDaiContract(),
59
59
  GNOContract(),
@@ -62,10 +62,10 @@ SAFE_COLLATERAL_TOKENS = (
62
62
  SAFEContract(),
63
63
  COWContract(),
64
64
  MetriSuperGroup(),
65
- )
66
- SAFE_COLLATERAL_TOKENS_ADDRESSES = tuple(
65
+ ]
66
+ SAFE_COLLATERAL_TOKENS_ADDRESSES = [
67
67
  contract.address for contract in SAFE_COLLATERAL_TOKENS
68
- )
68
+ ]
69
69
 
70
70
 
71
71
  class OmenSubgraphHandler(BaseSubgraphHandler):
@@ -237,7 +237,7 @@ class OmenSubgraphHandler(BaseSubgraphHandler):
237
237
  liquidity_bigger_than: Wei | None,
238
238
  condition_id_in: list[HexBytes] | None,
239
239
  id_in: list[str] | None,
240
- collateral_token_address_in: tuple[ChecksumAddress, ...] | None,
240
+ collateral_token_address_in: t.Sequence[ChecksumAddress] | None,
241
241
  category: str | None,
242
242
  include_categorical_markets: bool = False,
243
243
  include_scalar_markets: bool = False,
@@ -348,7 +348,7 @@ class OmenSubgraphHandler(BaseSubgraphHandler):
348
348
  created_after: DatetimeUTC | None = None,
349
349
  excluded_questions: set[str] | None = None, # question titles
350
350
  collateral_token_address_in: (
351
- tuple[ChecksumAddress, ...] | None
351
+ t.Sequence[ChecksumAddress] | None
352
352
  ) = SAFE_COLLATERAL_TOKENS_ADDRESSES,
353
353
  category: str | None = None,
354
354
  creator_in: t.Sequence[HexAddress] | None = None,
@@ -416,7 +416,7 @@ class OmenSubgraphHandler(BaseSubgraphHandler):
416
416
  sort_by_field: FieldPath | None = None,
417
417
  sort_direction: str | None = None,
418
418
  collateral_token_address_in: (
419
- tuple[ChecksumAddress, ...] | None
419
+ t.Sequence[ChecksumAddress] | None
420
420
  ) = SAFE_COLLATERAL_TOKENS_ADDRESSES,
421
421
  category: str | None = None,
422
422
  include_categorical_markets: bool = True,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.66.2
3
+ Version: 0.66.3
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -28,7 +28,7 @@ prediction_market_agent_tooling/config.py,sha256=-kJfdDr-m0R-tGZ1KRI-hJJk0mXDt14
28
28
  prediction_market_agent_tooling/data_download/langfuse_data_downloader.py,sha256=VY23h324VKIVkevj1B1O-zL1eEp9AElmcfn6SwYDUSc,14246
29
29
  prediction_market_agent_tooling/deploy/agent.py,sha256=EEAZQnOqsru1xRzt141iBy_9tG7zo1vnxkLqpg1SuDw,26313
30
30
  prediction_market_agent_tooling/deploy/agent_example.py,sha256=yS1fWkHynr9MYGNOM2WsCnRWLPaffY4bOc6bIudrdd4,1377
31
- prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=jyBz1vIRXWxzDoC5AeO-r-V6qntaSfJ-QoHSc_I7JBM,20268
31
+ prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=wiUV_zyB9ASLH-VUETIme0H_IMih8jZwiwEmcRa3W5Q,21125
32
32
  prediction_market_agent_tooling/deploy/constants.py,sha256=Qe9cllgsGMkecfmbhXoFkPxuJyG6ATsrT87RF9SmPWM,249
33
33
  prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
34
34
  prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
@@ -62,7 +62,7 @@ prediction_market_agent_tooling/markets/omen/omen.py,sha256=fYDP64-gL3n18K86BXMr
62
62
  prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=XtRk4vpxwUYkTndfjlcmghA-NOIneV8zdHFdyI7tHhM,487
63
63
  prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=27-HRngTqfk_wgvttB3GeVHhy_O2YZcz9izo9OufOI0,29991
64
64
  prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=D-ubf_LumHs_c5rBAAntQ8wGKprtO2V1JZeedmChNIE,11035
65
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=h-YFRLY5rlhM9RqqceyfbHlno3elltN8Nr_Mnu1kJ90,40006
65
+ prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=2fLlPa5EYPmc2Oa2qilR3Z5qZv-q7xJECN9Hvaj3LB4,40001
66
66
  prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
67
67
  prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=U1SXTz93FIG3GO1h5BJWSt1hPKn_YAMBeZ3k8IS-ook,4552
68
68
  prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=wCwpZ8Kppy8JG_1HZDfEK_Gg1g1sL7NCbGoPeTeMSko,12756
@@ -125,8 +125,8 @@ prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMD
125
125
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
126
126
  prediction_market_agent_tooling/tools/utils.py,sha256=RlWSlzS2LavMIWrpwn1fevbzgPZruD4VcXTa-XxjWnE,7343
127
127
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=0r26snqCXGdLKCWA8jpe7DV8x2NPYWZwOy4oyKyDCYk,12615
128
- prediction_market_agent_tooling-0.66.2.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
129
- prediction_market_agent_tooling-0.66.2.dist-info/METADATA,sha256=LrUMj4jSVZ9kX_y8LfK8xuGtbNElU3PnpqbJDPSjs_8,8726
130
- prediction_market_agent_tooling-0.66.2.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
131
- prediction_market_agent_tooling-0.66.2.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
132
- prediction_market_agent_tooling-0.66.2.dist-info/RECORD,,
128
+ prediction_market_agent_tooling-0.66.3.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
129
+ prediction_market_agent_tooling-0.66.3.dist-info/METADATA,sha256=zW4isyxA9kXcMHO8I9V2FcsLMdcjriSD-kKmko9uAZs,8726
130
+ prediction_market_agent_tooling-0.66.3.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
131
+ prediction_market_agent_tooling-0.66.3.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
132
+ prediction_market_agent_tooling-0.66.3.dist-info/RECORD,,