prediction-market-agent-tooling 0.68.0.dev999__tar.gz → 0.69.0__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.
Files changed (141) hide show
  1. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/PKG-INFO +8 -7
  2. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/chains.py +1 -0
  3. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/config.py +37 -2
  4. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/agent.py +26 -21
  5. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/betting_strategy.py +133 -22
  6. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/jobs/jobs_models.py +2 -2
  7. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +17 -20
  8. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/agent_market.py +27 -9
  9. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/blockchain_utils.py +3 -3
  10. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/markets.py +16 -0
  11. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/data_models.py +3 -18
  12. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/omen.py +26 -11
  13. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +2 -196
  14. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +2 -2
  15. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +13 -11
  16. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/polymarket/api.py +35 -1
  17. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/polymarket/clob_manager.py +156 -0
  18. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/polymarket/constants.py +15 -0
  19. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/polymarket/data_models.py +33 -5
  20. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/polymarket/polymarket.py +411 -0
  21. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/polymarket/polymarket_contracts.py +35 -0
  22. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/polymarket/polymarket_subgraph_handler.py +2 -1
  23. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/data_models.py +41 -6
  24. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/price_manager.py +69 -1
  25. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/seer.py +77 -26
  26. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/seer/seer_api.py +28 -0
  27. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +71 -20
  28. prediction_market_agent_tooling-0.69.0/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +127 -0
  29. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +17 -22
  30. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/contract.py +236 -4
  31. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/cow/cow_order.py +13 -8
  32. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/datetime_utc.py +14 -2
  33. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/hexbytes_custom.py +3 -9
  34. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +17 -5
  35. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +2 -2
  36. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/usd.py +5 -2
  37. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/web3_utils.py +9 -4
  38. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/pyproject.toml +9 -8
  39. prediction_market_agent_tooling-0.68.0.dev999/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -366
  40. prediction_market_agent_tooling-0.68.0.dev999/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -182
  41. prediction_market_agent_tooling-0.68.0.dev999/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -60
  42. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/LICENSE +0 -0
  43. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/README.md +0 -0
  44. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/agentresultmapping.abi.json +0 -0
  45. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
  46. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
  47. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/erc1155.abi.json +0 -0
  48. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
  49. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
  50. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
  51. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
  52. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
  53. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
  54. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
  55. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
  56. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
  57. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
  58. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
  59. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
  60. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
  61. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
  62. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
  63. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json +0 -0
  64. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
  65. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/abis/swapr_router.abi.json +0 -0
  66. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
  67. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
  68. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
  69. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
  70. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/data_download/langfuse_data_downloader.py +0 -0
  71. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
  72. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/constants.py +0 -0
  73. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
  74. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
  75. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
  76. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
  77. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/gtypes.py +0 -0
  78. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
  79. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/loggers.py +0 -0
  80. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/logprobs_parser.py +0 -0
  81. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
  82. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/categorize.py +0 -0
  83. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/data_models.py +0 -0
  84. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
  85. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
  86. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
  87. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
  88. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
  89. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
  90. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
  91. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
  92. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
  93. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
  94. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
  95. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
  96. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
  97. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/exceptions.py +0 -0
  98. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
  99. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/markets/seer/swap_pool_handler.py +0 -0
  100. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/py.typed +0 -0
  101. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
  102. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/balances.py +0 -0
  103. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
  104. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
  105. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
  106. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
  107. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
  108. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/costs.py +0 -0
  109. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/cow/models.py +0 -0
  110. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/cow/semaphore.py +0 -0
  111. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
  112. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
  113. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
  114. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
  115. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
  116. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
  117. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
  118. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
  119. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
  120. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
  121. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
  122. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
  123. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
  124. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/perplexity/perplexity_client.py +0 -0
  125. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/perplexity/perplexity_models.py +0 -0
  126. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/perplexity/perplexity_search.py +0 -0
  127. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
  128. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
  129. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
  130. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/rephrase.py +0 -0
  131. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/safe.py +0 -0
  132. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/singleton.py +0 -0
  133. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
  134. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
  135. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
  136. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
  137. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
  138. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/slippage.py +0 -0
  139. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
  140. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
  141. {prediction_market_agent_tooling-0.68.0.dev999 → prediction_market_agent_tooling-0.69.0}/prediction_market_agent_tooling/tools/utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.68.0.dev999
3
+ Version: 0.69.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -14,11 +14,11 @@ Provides-Extra: openai
14
14
  Provides-Extra: optuna
15
15
  Requires-Dist: autoflake (>=2.2.1,<3.0.0)
16
16
  Requires-Dist: base58 (>=1.0.2,<2.0)
17
- Requires-Dist: cowdao-cowpy (==1.0.0rc5)
17
+ Requires-Dist: cowdao-cowpy (==1.0.1)
18
18
  Requires-Dist: cron-validator (>=1.0.8,<2.0.0)
19
- Requires-Dist: eth-account (>=0.8.0,<0.12.0)
19
+ Requires-Dist: eth-account (>=0.13.0,<0.14.0)
20
20
  Requires-Dist: eth-keys (>=0.6.1,<0.7.0)
21
- Requires-Dist: eth-typing (>=3.0.0,<4.0.0)
21
+ Requires-Dist: eth-typing (>=5.0.0,<6.0.0)
22
22
  Requires-Dist: functions-framework (>=3.5.0,<4.0.0)
23
23
  Requires-Dist: google-api-python-client (==2.95.0) ; extra == "google"
24
24
  Requires-Dist: google-cloud-functions (>=1.16.0,<2.0.0)
@@ -41,6 +41,7 @@ Requires-Dist: prompt-toolkit (>=3.0.43,<4.0.0)
41
41
  Requires-Dist: proto-plus (>=1.0.0,<2.0.0)
42
42
  Requires-Dist: protobuf (>=5.0.0,<6.0.0)
43
43
  Requires-Dist: psycopg2-binary (>=2.9.9,<3.0.0)
44
+ Requires-Dist: py-clob-client (>=0.24.0,<0.25.0)
44
45
  Requires-Dist: pydantic (>=2.6.1,<3.0.0)
45
46
  Requires-Dist: pydantic-ai (>=0.1.9,<1.0.0)
46
47
  Requires-Dist: pydantic-settings (>=2.4.0,<3.0.0)
@@ -48,8 +49,8 @@ Requires-Dist: pymongo (>=4.8.0,<5.0.0)
48
49
  Requires-Dist: pytest-postgresql (>=6.1.1,<7.0.0)
49
50
  Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
50
51
  Requires-Dist: python-json-logger (>=3.3.0,<4.0.0)
51
- Requires-Dist: safe-cli (>=1.0.0,<2.0.0)
52
- Requires-Dist: safe-eth-py (>=6.0.0b41,<7.0.0)
52
+ Requires-Dist: safe-cli (>=1.5.0,<2.0.0)
53
+ Requires-Dist: safe-eth-py (>=7.8.0,<8.0.0)
53
54
  Requires-Dist: scikit-learn (>=1.3.1,<2.0.0)
54
55
  Requires-Dist: sqlmodel (>=0.0.22,<0.0.23)
55
56
  Requires-Dist: streamlit (>=1.31.0,<2.0.0)
@@ -62,7 +63,7 @@ Requires-Dist: types-cachetools (>=5.5.0.20240820,<6.0.0.0)
62
63
  Requires-Dist: types-python-dateutil (>=2.9.0.20240906,<3.0.0.0)
63
64
  Requires-Dist: types-pytz (>=2024.1.0.20240203,<2025.0.0.0)
64
65
  Requires-Dist: types-requests (>=2.31.0.0,<3.0.0.0)
65
- Requires-Dist: web3 (>=6.15.1,<7.0.0)
66
+ Requires-Dist: web3 (>=6,<8)
66
67
  Description-Content-Type: text/markdown
67
68
 
68
69
  # Prediction Market Agent Tooling
@@ -2,3 +2,4 @@ from prediction_market_agent_tooling.gtypes import ChainID
2
2
 
3
3
  ETHEREUM_ID = ChainID(1)
4
4
  GNOSIS_CHAIN_ID = ChainID(100)
5
+ POLYGON_CHAIN_ID = ChainID(137)
@@ -2,6 +2,7 @@ import json
2
2
  import typing as t
3
3
  from copy import deepcopy
4
4
 
5
+ import cachetools
5
6
  from eth_account.signers.local import LocalAccount
6
7
  from eth_typing import URI
7
8
  from pydantic import Field, model_validator
@@ -12,8 +13,13 @@ from safe_eth.eth import EthereumClient
12
13
  from safe_eth.safe.safe import SafeV141
13
14
  from web3 import Account, Web3
14
15
  from web3._utils.http import construct_user_agent
16
+ from web3.middleware import ExtraDataToPOAMiddleware
15
17
 
16
- from prediction_market_agent_tooling.chains import ETHEREUM_ID, GNOSIS_CHAIN_ID
18
+ from prediction_market_agent_tooling.chains import (
19
+ ETHEREUM_ID,
20
+ GNOSIS_CHAIN_ID,
21
+ POLYGON_CHAIN_ID,
22
+ )
17
23
  from prediction_market_agent_tooling.deploy.gcp.utils import gcp_get_secret_value
18
24
  from prediction_market_agent_tooling.gtypes import (
19
25
  ChainID,
@@ -293,6 +299,8 @@ class RPCConfig(BaseSettings):
293
299
  GNOSIS_RPC_URL: URI = Field(default=URI("https://rpc.gnosis.gateway.fm"))
294
300
  GNOSIS_RPC_BEARER: SecretStr | None = None
295
301
  CHAIN_ID: ChainID = Field(default=GNOSIS_CHAIN_ID)
302
+ POLYGON_RPC_URL: URI = Field(default=URI("https://polygon-rpc.com"))
303
+ POLYGON_RPC_BEARER: SecretStr | None = None
296
304
 
297
305
  @property
298
306
  def ethereum_rpc_url(self) -> URI:
@@ -306,26 +314,40 @@ class RPCConfig(BaseSettings):
306
314
  self.GNOSIS_RPC_URL, "GNOSIS_RPC_URL missing in the environment."
307
315
  )
308
316
 
317
+ @property
318
+ def polygon_rpc_url(self) -> URI:
319
+ return check_not_none(
320
+ self.POLYGON_RPC_URL, "POLYGON_RPC_URL missing in the environment."
321
+ )
322
+
309
323
  @property
310
324
  def chain_id(self) -> ChainID:
311
325
  return check_not_none(self.CHAIN_ID, "CHAIN_ID missing in the environment.")
312
326
 
327
+ @property
328
+ def gnosis_chain_id(self) -> ChainID:
329
+ return GNOSIS_CHAIN_ID
330
+
313
331
  def chain_id_to_rpc_url(self, chain_id: ChainID) -> URI:
314
332
  return {
315
333
  ETHEREUM_ID: self.ethereum_rpc_url,
316
334
  GNOSIS_CHAIN_ID: self.gnosis_rpc_url,
335
+ POLYGON_CHAIN_ID: self.polygon_rpc_url,
317
336
  }[chain_id]
318
337
 
319
338
  def chain_id_to_rpc_bearer(self, chain_id: ChainID) -> SecretStr | None:
320
339
  return {
321
340
  ETHEREUM_ID: self.ETHEREUM_RPC_BEARER,
322
341
  GNOSIS_CHAIN_ID: self.GNOSIS_RPC_BEARER,
342
+ POLYGON_CHAIN_ID: self.POLYGON_RPC_BEARER,
323
343
  }[chain_id]
324
344
 
325
345
  def get_web3(self) -> Web3:
326
346
  headers = {
327
347
  "Content-Type": "application/json",
328
- "User-Agent": construct_user_agent(str(type(self))),
348
+ "User-Agent": construct_user_agent(
349
+ str(type(self)), self.__class__.__name__
350
+ ),
329
351
  }
330
352
  if bearer := self.chain_id_to_rpc_bearer(self.chain_id):
331
353
  headers["Authorization"] = f"Bearer {bearer.get_secret_value()}"
@@ -339,6 +361,19 @@ class RPCConfig(BaseSettings):
339
361
  )
340
362
  )
341
363
 
364
+ @cachetools.cached(
365
+ cachetools.TTLCache(maxsize=100, ttl=5 * 60),
366
+ key=lambda self: f"{self.model_dump_json()}",
367
+ )
368
+ def get_polygon_web3(self) -> Web3:
369
+ web3 = self.get_web3()
370
+ if self.chain_id != POLYGON_CHAIN_ID:
371
+ raise ValueError(f"Chain ID {self.chain_id} is not Polygon Mainnet")
372
+
373
+ # We need to inject middleware into the Polygon web3 instance (https://web3py.readthedocs.io/en/stable/middleware.html#proof-of-authority)
374
+ web3.middleware_onion.inject(ExtraDataToPOAMiddleware, layer=0)
375
+ return web3
376
+
342
377
 
343
378
  class CloudCredentials(BaseSettings):
344
379
  model_config = SettingsConfigDict(
@@ -25,7 +25,6 @@ from prediction_market_agent_tooling.markets.agent_market import (
25
25
  ConditionalFilterType,
26
26
  FilterBy,
27
27
  ProcessedMarket,
28
- ProcessedTradedMarket,
29
28
  QuestionType,
30
29
  SortBy,
31
30
  )
@@ -38,9 +37,6 @@ from prediction_market_agent_tooling.markets.data_models import (
38
37
  Trade,
39
38
  )
40
39
  from prediction_market_agent_tooling.markets.markets import MarketType
41
- from prediction_market_agent_tooling.markets.omen.omen import (
42
- send_keeping_token_to_eoa_xdai,
43
- )
44
40
  from prediction_market_agent_tooling.tools.custom_exceptions import (
45
41
  CantPayForGasError,
46
42
  OutOfFundsError,
@@ -414,15 +410,13 @@ class DeployablePredictionAgent(DeployableAgent):
414
410
  """
415
411
  Executed before processing of each market.
416
412
  """
417
- api_keys = APIKeys()
418
413
 
419
414
  if market_type.is_blockchain_market:
420
- # Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
415
+ # Ensure we have enough native token balance for transaction fees
421
416
  if self.min_balance_to_keep_in_native_currency is not None:
422
- send_keeping_token_to_eoa_xdai(
423
- api_keys,
417
+ market.ensure_min_native_balance(
424
418
  min_required_balance=self.min_balance_to_keep_in_native_currency,
425
- multiplier=3,
419
+ multiplier=3.0,
426
420
  )
427
421
 
428
422
  def build_answer(
@@ -515,7 +509,7 @@ class DeployablePredictionAgent(DeployableAgent):
515
509
  self.verify_answer_outcomes(market=market, answer=answer)
516
510
 
517
511
  processed_market = (
518
- ProcessedMarket(answer=answer) if answer is not None else None
512
+ ProcessedMarket(answer=answer, trades=[]) if answer is not None else None
519
513
  )
520
514
 
521
515
  self.update_langfuse_trace_by_processed_market(market_type, processed_market)
@@ -636,7 +630,7 @@ class DeployableTraderAgent(DeployablePredictionAgent):
636
630
  api_keys = APIKeys()
637
631
 
638
632
  # Get the strategy to know how much it will bet.
639
- strategy = self.get_betting_strategy(market)
633
+ strategy = self.get_betting_strategy_supported(market)
640
634
  # Have a little bandwidth after the bet.
641
635
  min_required_balance_to_trade = strategy.maximum_possible_bet_amount * 1.01
642
636
 
@@ -664,13 +658,24 @@ class DeployableTraderAgent(DeployablePredictionAgent):
664
658
  total_amount = self.get_total_amount_to_bet(market)
665
659
  return CategoricalMaxAccuracyBettingStrategy(max_position_amount=total_amount)
666
660
 
661
+ def get_betting_strategy_supported(self, market: AgentMarket) -> BettingStrategy:
662
+ """
663
+ Use this class internally to assert that the configured betting strategy works with the given market.
664
+ """
665
+ strategy = self.get_betting_strategy(market=market)
666
+ if not strategy.is_market_supported(market):
667
+ raise ValueError(
668
+ f"Market {market.url} is not supported by the strategy {strategy}."
669
+ )
670
+ return strategy
671
+
667
672
  def build_trades(
668
673
  self,
669
674
  market: AgentMarket,
670
675
  answer: CategoricalProbabilisticAnswer,
671
676
  existing_position: ExistingPosition | None,
672
677
  ) -> list[Trade]:
673
- strategy = self.get_betting_strategy(market=market)
678
+ strategy = self.get_betting_strategy_supported(market=market)
674
679
  trades = strategy.calculate_trades(existing_position, answer, market)
675
680
  return trades
676
681
 
@@ -742,7 +747,7 @@ class DeployableTraderAgent(DeployablePredictionAgent):
742
747
  market_type: MarketType,
743
748
  market: AgentMarket,
744
749
  verify_market: bool = True,
745
- ) -> ProcessedTradedMarket | None:
750
+ ) -> ProcessedMarket | None:
746
751
  processed_market = super().process_market(market_type, market, verify_market)
747
752
  if processed_market is None:
748
753
  return None
@@ -762,7 +767,7 @@ class DeployableTraderAgent(DeployablePredictionAgent):
762
767
  )
763
768
  placed_trades = self.execute_trades(market, trades)
764
769
 
765
- traded_market = ProcessedTradedMarket(
770
+ traded_market = ProcessedMarket(
766
771
  answer=processed_market.answer, trades=placed_trades
767
772
  )
768
773
  logger.info(f"Traded market {market.question=} from {market.url=}.")
@@ -780,10 +785,10 @@ class DeployableTraderAgent(DeployablePredictionAgent):
780
785
  market,
781
786
  processed_market,
782
787
  )
783
- if isinstance(processed_market, ProcessedTradedMarket):
784
- if self.store_trades:
785
- market.store_trades(processed_market, api_keys, self.agent_name)
786
- else:
787
- logger.info(
788
- f"Trades {processed_market.trades} not stored because {self.store_trades=}."
789
- )
788
+
789
+ if self.store_trades and processed_market is not None:
790
+ market.store_trades(processed_market, api_keys, self.agent_name)
791
+ else:
792
+ logger.info(
793
+ f"Trades {processed_market=} not stored because {self.store_trades=}."
794
+ )
@@ -16,7 +16,11 @@ from prediction_market_agent_tooling.gtypes import (
16
16
  Probability,
17
17
  )
18
18
  from prediction_market_agent_tooling.loggers import logger
19
- from prediction_market_agent_tooling.markets.agent_market import AgentMarket, MarketFees
19
+ from prediction_market_agent_tooling.markets.agent_market import (
20
+ AgentMarket,
21
+ MarketFees,
22
+ QuestionType,
23
+ )
20
24
  from prediction_market_agent_tooling.markets.data_models import (
21
25
  CategoricalProbabilisticAnswer,
22
26
  ExistingPosition,
@@ -24,10 +28,12 @@ from prediction_market_agent_tooling.markets.data_models import (
24
28
  Trade,
25
29
  TradeType,
26
30
  )
31
+ from prediction_market_agent_tooling.markets.markets import MarketType
27
32
  from prediction_market_agent_tooling.markets.omen.omen import (
28
33
  get_buy_outcome_token_amount,
29
34
  )
30
35
  from prediction_market_agent_tooling.tools.betting_strategies.kelly_criterion import (
36
+ KellyType,
31
37
  get_kelly_bet_full,
32
38
  get_kelly_bet_simplified,
33
39
  get_kelly_bets_categorical_full,
@@ -45,9 +51,21 @@ class GuaranteedLossError(RuntimeError):
45
51
 
46
52
 
47
53
  class BettingStrategy(ABC):
54
+ supported_question_types: set[QuestionType]
55
+ supported_market_types: set[MarketType]
56
+
48
57
  def __init__(self, take_profit: bool = True) -> None:
49
58
  self.take_profit = take_profit
50
59
 
60
+ def is_market_supported(self, market: AgentMarket) -> bool:
61
+ if market.question_type not in self.supported_question_types:
62
+ return False
63
+
64
+ if MarketType.from_market(market) not in self.supported_market_types:
65
+ return False
66
+
67
+ return True
68
+
51
69
  @abstractmethod
52
70
  def calculate_trades(
53
71
  self,
@@ -251,6 +269,13 @@ class BettingStrategy(ABC):
251
269
 
252
270
 
253
271
  class CategoricalMaxAccuracyBettingStrategy(BettingStrategy):
272
+ supported_question_types = {
273
+ QuestionType.BINARY,
274
+ QuestionType.CATEGORICAL,
275
+ QuestionType.SCALAR,
276
+ }
277
+ supported_market_types = {x for x in MarketType if x.is_trading_market}
278
+
254
279
  def __init__(self, max_position_amount: USD, take_profit: bool = True):
255
280
  super().__init__(take_profit=take_profit)
256
281
  self.max_position_amount = max_position_amount
@@ -362,18 +387,20 @@ class MaxExpectedValueBettingStrategy(CategoricalMaxAccuracyBettingStrategy):
362
387
  return f"MaxExpectedValueBettingStrategy(max_position_amount={self.max_position_amount}, take_profit={self.take_profit})"
363
388
 
364
389
 
365
- class BinaryKellyBettingStrategy(BettingStrategy):
390
+ class _BinaryKellyBettingStrategy(BettingStrategy):
391
+ supported_question_types = {QuestionType.BINARY}
392
+
366
393
  def __init__(
367
394
  self,
395
+ kelly_type: KellyType,
368
396
  max_position_amount: USD,
369
397
  max_price_impact: float | None = None,
370
398
  take_profit: bool = True,
371
- force_simplified_calculation: bool = False,
372
399
  ):
373
400
  super().__init__(take_profit=take_profit)
401
+ self.kelly_type = kelly_type
374
402
  self.max_position_amount = max_position_amount
375
403
  self.max_price_impact = max_price_impact
376
- self.force_simplified_calculation = force_simplified_calculation
377
404
 
378
405
  @property
379
406
  def maximum_possible_bet_amount(self) -> USD:
@@ -396,7 +423,7 @@ class BinaryKellyBettingStrategy(BettingStrategy):
396
423
  else override_p_yes
397
424
  )
398
425
 
399
- if market.outcome_token_pool is None or self.force_simplified_calculation:
426
+ if self.kelly_type == KellyType.SIMPLE:
400
427
  kelly_bet = get_kelly_bet_simplified(
401
428
  max_bet=market.get_usd_in_token(self.max_position_amount),
402
429
  market_p_yes=market.probability_for_market_outcome(direction),
@@ -447,7 +474,6 @@ class BinaryKellyBettingStrategy(BettingStrategy):
447
474
  # Adjust amount
448
475
  max_price_impact_bet_amount = self.calculate_bet_amount_for_price_impact(
449
476
  market,
450
- kelly_bet.size,
451
477
  direction=direction,
452
478
  max_price_impact=self.max_price_impact,
453
479
  )
@@ -460,7 +486,9 @@ class BinaryKellyBettingStrategy(BettingStrategy):
460
486
  amounts = {
461
487
  bet_outcome: BettingStrategy.cap_to_profitable_bet_amount(
462
488
  market, market.get_token_in_usd(kelly_bet_size), bet_outcome
463
- ),
489
+ )
490
+ if kelly_bet_size > 0
491
+ else USD(0),
464
492
  }
465
493
  target_position = Position(market_id=market.id, amounts_current=amounts)
466
494
  trades = self._build_rebalance_trades_from_positions(
@@ -490,7 +518,6 @@ class BinaryKellyBettingStrategy(BettingStrategy):
490
518
  @staticmethod
491
519
  def calculate_bet_amount_for_price_impact(
492
520
  market: AgentMarket,
493
- kelly_bet_size: CollateralToken,
494
521
  direction: OutcomeStr,
495
522
  max_price_impact: float,
496
523
  ) -> CollateralToken:
@@ -499,7 +526,7 @@ class BinaryKellyBettingStrategy(BettingStrategy):
499
526
  ) -> float:
500
527
  outcome_idx = market.get_outcome_index(direction)
501
528
  price_impact = (
502
- BinaryKellyBettingStrategy.calculate_price_impact_for_bet_amount(
529
+ _BinaryKellyBettingStrategy.calculate_price_impact_for_bet_amount(
503
530
  outcome_idx=outcome_idx,
504
531
  bet_amount=CollateralToken(bet_amount_collateral),
505
532
  pool_balances=pool_balances,
@@ -510,10 +537,9 @@ class BinaryKellyBettingStrategy(BettingStrategy):
510
537
  return abs(price_impact - max_price_impact)
511
538
 
512
539
  if not market.outcome_token_pool:
513
- logger.warning(
540
+ raise ValueError(
514
541
  "Market outcome_token_pool is None, cannot calculate bet amount"
515
542
  )
516
- return kelly_bet_size
517
543
 
518
544
  pool_balances = [i.as_outcome_wei for i in market.outcome_token_pool.values()]
519
545
  # stay float for compatibility with `minimize_scalar`
@@ -530,10 +556,47 @@ class BinaryKellyBettingStrategy(BettingStrategy):
530
556
  return CollateralToken(optimized_bet_amount.x)
531
557
 
532
558
  def __repr__(self) -> str:
533
- return f"{self.__class__.__name__}(max_position_amount={self.max_position_amount}, max_price_impact={self.max_price_impact}, take_profit={self.take_profit}, force_simplified_calculation={self.force_simplified_calculation})"
559
+ return f"{self.__class__.__name__}(max_position_amount={self.max_position_amount}, max_price_impact={self.max_price_impact}, take_profit={self.take_profit})"
560
+
561
+
562
+ class SimpleBinaryKellyBettingStrategy(_BinaryKellyBettingStrategy):
563
+ supported_market_types = {x for x in MarketType if x.is_trading_market}
564
+
565
+ def __init__(
566
+ self,
567
+ max_position_amount: USD,
568
+ take_profit: bool = True,
569
+ ):
570
+ super().__init__(
571
+ kelly_type=KellyType.SIMPLE,
572
+ max_position_amount=max_position_amount,
573
+ max_price_impact=None,
574
+ take_profit=take_profit,
575
+ )
576
+
577
+
578
+ class FullBinaryKellyBettingStrategy(_BinaryKellyBettingStrategy):
579
+ # Supports only OMEN because it uses closed-form formula derived from a binary FPMM.
580
+ supported_market_types = {MarketType.OMEN}
581
+
582
+ def __init__(
583
+ self,
584
+ max_position_amount: USD,
585
+ max_price_impact: float | None = None,
586
+ take_profit: bool = True,
587
+ ):
588
+ super().__init__(
589
+ kelly_type=KellyType.FULL,
590
+ max_position_amount=max_position_amount,
591
+ max_price_impact=max_price_impact,
592
+ take_profit=take_profit,
593
+ )
534
594
 
535
595
 
536
596
  class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
597
+ supported_question_types = {QuestionType.BINARY}
598
+ supported_market_types = {MarketType.OMEN}
599
+
537
600
  def __init__(
538
601
  self,
539
602
  max_position_amount: USD,
@@ -565,7 +628,7 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
565
628
  # We ignore the direction nudge given by Kelly, hence we assume we have a perfect prediction.
566
629
  estimated_p_yes = 1.0
567
630
 
568
- kelly_bet = BinaryKellyBettingStrategy(
631
+ kelly_bet = FullBinaryKellyBettingStrategy(
569
632
  max_position_amount=self.max_position_amount
570
633
  ).get_kelly_bet(
571
634
  market=market,
@@ -593,24 +656,27 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
593
656
  return f"{self.__class__.__name__}(max_position_amount={self.max_position_amount}, take_profit={self.take_profit})"
594
657
 
595
658
 
596
- class CategoricalKellyBettingStrategy(BettingStrategy):
659
+ class _CategoricalKellyBettingStrategy(BettingStrategy):
660
+ supported_question_types = {QuestionType.BINARY, QuestionType.CATEGORICAL}
661
+ supported_market_types = {x for x in MarketType if x.is_trading_market}
662
+
597
663
  def __init__(
598
664
  self,
665
+ kelly_type: KellyType,
599
666
  max_position_amount: USD,
600
667
  max_price_impact: float | None,
601
668
  allow_multiple_bets: bool,
602
669
  allow_shorting: bool,
603
670
  multicategorical: bool,
604
671
  take_profit: bool = True,
605
- force_simplified_calculation: bool = False,
606
672
  ):
607
673
  super().__init__(take_profit=take_profit)
674
+ self.kelly_type = kelly_type
608
675
  self.max_position_amount = max_position_amount
609
676
  self.max_price_impact = max_price_impact
610
677
  self.allow_multiple_bets = allow_multiple_bets
611
678
  self.allow_shorting = allow_shorting
612
679
  self.multicategorical = multicategorical
613
- self.force_simplified_calculation = force_simplified_calculation
614
680
 
615
681
  @property
616
682
  def maximum_possible_bet_amount(self) -> USD:
@@ -624,7 +690,7 @@ class CategoricalKellyBettingStrategy(BettingStrategy):
624
690
  ) -> list[CategoricalKellyBet]:
625
691
  max_bet = market.get_usd_in_token(max_bet_amount)
626
692
 
627
- if market.outcome_token_pool is None or self.force_simplified_calculation:
693
+ if self.kelly_type == KellyType.SIMPLE:
628
694
  kelly_bets = get_kelly_bets_categorical_simplified(
629
695
  market_probabilities=[market.probabilities[o] for o in market.outcomes],
630
696
  estimated_probabilities=[
@@ -639,8 +705,8 @@ class CategoricalKellyBettingStrategy(BettingStrategy):
639
705
 
640
706
  else:
641
707
  kelly_bets = get_kelly_bets_categorical_full(
642
- outcome_pool_sizes=[
643
- market.outcome_token_pool[o] for o in market.outcomes
708
+ market_probabilities=[
709
+ market.probability_for_market_outcome(o) for o in market.outcomes
644
710
  ],
645
711
  estimated_probabilities=[
646
712
  answer.probability_for_market_outcome(o) for o in market.outcomes
@@ -651,6 +717,11 @@ class CategoricalKellyBettingStrategy(BettingStrategy):
651
717
  allow_multiple_bets=self.allow_multiple_bets,
652
718
  allow_shorting=self.allow_shorting,
653
719
  multicategorical=self.multicategorical,
720
+ get_buy_token_amount=lambda bet_amount, outcome_index: check_not_none(
721
+ market.get_buy_token_amount(
722
+ bet_amount, market.get_outcome_str(outcome_index)
723
+ )
724
+ ),
654
725
  )
655
726
 
656
727
  return kelly_bets
@@ -681,9 +752,8 @@ class CategoricalKellyBettingStrategy(BettingStrategy):
681
752
  if self.max_price_impact:
682
753
  # Adjust amount
683
754
  max_price_impact_bet_amount = (
684
- BinaryKellyBettingStrategy.calculate_bet_amount_for_price_impact(
755
+ _BinaryKellyBettingStrategy.calculate_bet_amount_for_price_impact(
685
756
  market,
686
- best_kelly_bet.size,
687
757
  direction=market.get_outcome_str(best_kelly_bet.index),
688
758
  max_price_impact=self.max_price_impact,
689
759
  )
@@ -704,4 +774,45 @@ class CategoricalKellyBettingStrategy(BettingStrategy):
704
774
  return trades
705
775
 
706
776
  def __repr__(self) -> str:
707
- return f"{self.__class__.__name__}(max_position_amount={self.max_position_amount}, max_price_impact={self.max_price_impact}, allow_multiple_bets={self.allow_multiple_bets}, allow_shorting={self.allow_shorting}, take_profit={self.take_profit}, force_simplified_calculation={self.force_simplified_calculation})"
777
+ return f"{self.__class__.__name__}(max_position_amount={self.max_position_amount}, max_price_impact={self.max_price_impact}, allow_multiple_bets={self.allow_multiple_bets}, allow_shorting={self.allow_shorting}, take_profit={self.take_profit})"
778
+
779
+
780
+ class SimpleCategoricalKellyBettingStrategy(_CategoricalKellyBettingStrategy):
781
+ def __init__(
782
+ self,
783
+ max_position_amount: USD,
784
+ allow_multiple_bets: bool,
785
+ allow_shorting: bool,
786
+ multicategorical: bool,
787
+ take_profit: bool = True,
788
+ ):
789
+ super().__init__(
790
+ kelly_type=KellyType.SIMPLE,
791
+ max_position_amount=max_position_amount,
792
+ max_price_impact=None,
793
+ allow_multiple_bets=allow_multiple_bets,
794
+ allow_shorting=allow_shorting,
795
+ multicategorical=multicategorical,
796
+ take_profit=take_profit,
797
+ )
798
+
799
+
800
+ class FullCategoricalKellyBettingStrategy(_CategoricalKellyBettingStrategy):
801
+ def __init__(
802
+ self,
803
+ max_position_amount: USD,
804
+ max_price_impact: float | None,
805
+ allow_multiple_bets: bool,
806
+ allow_shorting: bool,
807
+ multicategorical: bool,
808
+ take_profit: bool = True,
809
+ ):
810
+ super().__init__(
811
+ kelly_type=KellyType.FULL,
812
+ max_position_amount=max_position_amount,
813
+ max_price_impact=max_price_impact,
814
+ allow_multiple_bets=allow_multiple_bets,
815
+ allow_shorting=allow_shorting,
816
+ multicategorical=multicategorical,
817
+ take_profit=take_profit,
818
+ )
@@ -9,7 +9,7 @@ from prediction_market_agent_tooling.deploy.betting_strategy import (
9
9
  from prediction_market_agent_tooling.gtypes import USD, Probability
10
10
  from prediction_market_agent_tooling.markets.agent_market import (
11
11
  AgentMarket,
12
- ProcessedTradedMarket,
12
+ ProcessedMarket,
13
13
  )
14
14
  from prediction_market_agent_tooling.markets.omen.data_models import (
15
15
  OMEN_FALSE_OUTCOME,
@@ -64,7 +64,7 @@ class JobAgentMarket(AgentMarket, ABC):
64
64
  @abstractmethod
65
65
  def submit_job_result(
66
66
  self, agent_name: str, max_bond: USD, result: str
67
- ) -> ProcessedTradedMarket:
67
+ ) -> ProcessedMarket:
68
68
  """Submit the completed result for this job."""
69
69
 
70
70
  def to_simple_job(self, max_bond: USD) -> SimpleJob:
@@ -1,13 +1,9 @@
1
1
  import typing as t
2
2
 
3
3
  from prediction_market_agent_tooling.config import APIKeys
4
- from prediction_market_agent_tooling.deploy.betting_strategy import (
5
- BinaryKellyBettingStrategy,
6
- TradeType,
7
- )
8
4
  from prediction_market_agent_tooling.gtypes import USD
9
5
  from prediction_market_agent_tooling.jobs.jobs_models import JobAgentMarket
10
- from prediction_market_agent_tooling.markets.agent_market import ProcessedTradedMarket
6
+ from prediction_market_agent_tooling.markets.agent_market import ProcessedMarket
11
7
  from prediction_market_agent_tooling.markets.data_models import PlacedTrade, Trade
12
8
  from prediction_market_agent_tooling.markets.omen.omen import (
13
9
  OmenAgentMarket,
@@ -72,7 +68,7 @@ class OmenJobAgentMarket(OmenAgentMarket, JobAgentMarket):
72
68
 
73
69
  def submit_job_result(
74
70
  self, agent_name: str, max_bond: USD, result: str
75
- ) -> ProcessedTradedMarket:
71
+ ) -> ProcessedMarket:
76
72
  if not APIKeys().enable_ipfs_upload:
77
73
  raise RuntimeError(
78
74
  f"ENABLE_IPFS_UPLOAD must be set to True to upload job results."
@@ -81,7 +77,7 @@ class OmenJobAgentMarket(OmenAgentMarket, JobAgentMarket):
81
77
  trade = self.get_job_trade(max_bond, result)
82
78
  buy_id = self.buy_tokens(outcome=trade.outcome, amount=trade.amount)
83
79
 
84
- processed_traded_market = ProcessedTradedMarket(
80
+ processed_traded_market = ProcessedMarket(
85
81
  answer=self.get_job_answer(result),
86
82
  trades=[PlacedTrade.from_trade(trade, id=buy_id)],
87
83
  )
@@ -92,20 +88,21 @@ class OmenJobAgentMarket(OmenAgentMarket, JobAgentMarket):
92
88
  return processed_traded_market
93
89
 
94
90
  def get_job_trade(self, max_bond: USD, result: str) -> Trade:
91
+ raise NotImplementedError("TODO: Refactor to avoid circular imports.")
95
92
  # Because jobs are powered by prediction markets, potentional reward depends on job's liquidity and our will to bond (bet) our xDai into our job completion.
96
- strategy = BinaryKellyBettingStrategy(max_position_amount=max_bond)
97
- required_trades = strategy.calculate_trades(
98
- existing_position=None,
99
- answer=self.get_job_answer(result),
100
- market=self,
101
- )
102
- assert (
103
- len(required_trades) == 1
104
- ), f"Shouldn't process same job twice: {required_trades}"
105
- trade = required_trades[0]
106
- assert trade.trade_type == TradeType.BUY, "Should only buy on job markets."
107
- assert trade.outcome, "Should buy only YES on job markets."
108
- return required_trades[0]
93
+ # strategy = FullBinaryKellyBettingStrategy(max_position_amount=max_bond)
94
+ # required_trades = strategy.calculate_trades(
95
+ # existing_position=None,
96
+ # answer=self.get_job_answer(result),
97
+ # market=self,
98
+ # )
99
+ # assert (
100
+ # len(required_trades) == 1
101
+ # ), f"Shouldn't process same job twice: {required_trades}"
102
+ # trade = required_trades[0]
103
+ # assert trade.trade_type == TradeType.BUY, "Should only buy on job markets."
104
+ # assert trade.outcome, "Should buy only YES on job markets."
105
+ # return required_trades[0]
109
106
 
110
107
  @staticmethod
111
108
  def from_omen_market(market: OmenMarket) -> "OmenJobAgentMarket":