prediction-market-agent-tooling 0.66.1__tar.gz → 0.66.3__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.66.1 → prediction_market_agent_tooling-0.66.3}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/agent.py +3 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/betting_strategy.py +125 -15
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/omen.py +2 -2
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +7 -7
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/seer.py +1 -3
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/pyproject.toml +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/README.md +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/seer_market_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/abis/swapr_router.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/chains.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/data_download/langfuse_data_downloader.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/logprobs_parser.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/blockchain_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/exceptions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/price_manager.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/subgraph_data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/markets/seer/swap_pool_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/cow/models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/cow/semaphore.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/perplexity/perplexity_client.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/perplexity/perplexity_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/perplexity/perplexity_search.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.3}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -571,7 +571,9 @@ class DeployableTraderAgent(DeployablePredictionAgent):
|
|
571
571
|
Given the market and prediction, agent uses this method to calculate optimal outcome and bet size.
|
572
572
|
"""
|
573
573
|
total_amount = self.get_total_amount_to_bet(market)
|
574
|
-
return MultiCategoricalMaxAccuracyBettingStrategy(
|
574
|
+
return MultiCategoricalMaxAccuracyBettingStrategy(
|
575
|
+
max_position_amount=total_amount
|
576
|
+
)
|
575
577
|
|
576
578
|
def build_trades(
|
577
579
|
self,
|
@@ -1,6 +1,7 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
from typing import Sequence
|
3
3
|
|
4
|
+
import numpy as np
|
4
5
|
from scipy.optimize import minimize_scalar
|
5
6
|
|
6
7
|
from prediction_market_agent_tooling.benchmark.utils import get_most_probable_outcome
|
@@ -39,6 +40,9 @@ class GuaranteedLossError(RuntimeError):
|
|
39
40
|
|
40
41
|
|
41
42
|
class BettingStrategy(ABC):
|
43
|
+
def __init__(self, take_profit: bool = True) -> None:
|
44
|
+
self.take_profit = take_profit
|
45
|
+
|
42
46
|
@abstractmethod
|
43
47
|
def calculate_trades(
|
44
48
|
self,
|
@@ -94,6 +98,76 @@ class BettingStrategy(ABC):
|
|
94
98
|
)
|
95
99
|
return trades
|
96
100
|
|
101
|
+
@staticmethod
|
102
|
+
def cap_to_profitable_bet_amount(
|
103
|
+
market: AgentMarket,
|
104
|
+
bet_amount: USD,
|
105
|
+
outcome: OutcomeStr,
|
106
|
+
iters: int = 10,
|
107
|
+
) -> USD:
|
108
|
+
"""
|
109
|
+
Use a binary search (tree-based search) to efficiently find the largest profitable bet amount.
|
110
|
+
"""
|
111
|
+
# First, try it with the desired amount right away.
|
112
|
+
if (
|
113
|
+
market.get_in_usd(
|
114
|
+
check_not_none(
|
115
|
+
market.get_buy_token_amount(bet_amount, outcome)
|
116
|
+
).as_token
|
117
|
+
)
|
118
|
+
> bet_amount
|
119
|
+
):
|
120
|
+
return bet_amount
|
121
|
+
|
122
|
+
# If it wasn't profitable, try binary search to find the highest, but profitable, amount.
|
123
|
+
lower = USD(0)
|
124
|
+
# It doesn't make sense to try to bet more than the liquidity itself, so override it as maximal value if it's lower.
|
125
|
+
upper = min(bet_amount, market.get_in_usd(market.get_liquidity()))
|
126
|
+
best_profitable = USD(0)
|
127
|
+
|
128
|
+
for _ in range(iters):
|
129
|
+
mid = (lower + upper) / 2
|
130
|
+
potential_outcome_value = market.get_in_usd(
|
131
|
+
check_not_none(market.get_buy_token_amount(mid, outcome)).as_token
|
132
|
+
)
|
133
|
+
|
134
|
+
if potential_outcome_value > mid:
|
135
|
+
# Profitable, try higher
|
136
|
+
best_profitable = mid
|
137
|
+
lower = mid
|
138
|
+
|
139
|
+
else:
|
140
|
+
# Not profitable, try lower
|
141
|
+
upper = mid
|
142
|
+
|
143
|
+
# If the search interval is very small, break early
|
144
|
+
if float(upper - lower) < 1e-8:
|
145
|
+
break
|
146
|
+
|
147
|
+
if np.isclose(best_profitable.value, 0):
|
148
|
+
best_profitable = USD(0)
|
149
|
+
|
150
|
+
return best_profitable
|
151
|
+
|
152
|
+
@staticmethod
|
153
|
+
def cap_to_profitable_position(
|
154
|
+
market: AgentMarket,
|
155
|
+
existing_position: USD,
|
156
|
+
wanted_position: USD,
|
157
|
+
outcome_to_bet_on: OutcomeStr,
|
158
|
+
) -> USD:
|
159
|
+
# If the wanted position is lower, it means the agent is gonna sell and that's profitable always.
|
160
|
+
if wanted_position > existing_position:
|
161
|
+
difference = wanted_position - existing_position
|
162
|
+
# Cap the difference we would like to buy to a profitable one.
|
163
|
+
capped_difference = BettingStrategy.cap_to_profitable_bet_amount(
|
164
|
+
market, difference, outcome_to_bet_on
|
165
|
+
)
|
166
|
+
# Lowered the actual wanted position such that it remains profitable.
|
167
|
+
wanted_position = existing_position + capped_difference
|
168
|
+
|
169
|
+
return wanted_position
|
170
|
+
|
97
171
|
def _build_rebalance_trades_from_positions(
|
98
172
|
self,
|
99
173
|
existing_position: ExistingPosition | None,
|
@@ -138,10 +212,22 @@ class BettingStrategy(ABC):
|
|
138
212
|
)
|
139
213
|
|
140
214
|
diff_amount = target_amount - existing_amount
|
215
|
+
|
141
216
|
if diff_amount == 0:
|
142
217
|
continue
|
143
218
|
|
144
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
|
+
|
145
231
|
trade = Trade(
|
146
232
|
amount=abs(diff_amount),
|
147
233
|
outcome=outcome,
|
@@ -160,12 +246,13 @@ class BettingStrategy(ABC):
|
|
160
246
|
|
161
247
|
|
162
248
|
class MultiCategoricalMaxAccuracyBettingStrategy(BettingStrategy):
|
163
|
-
def __init__(self,
|
164
|
-
|
249
|
+
def __init__(self, max_position_amount: USD, take_profit: bool = True):
|
250
|
+
super().__init__(take_profit=take_profit)
|
251
|
+
self.max_position_amount = max_position_amount
|
165
252
|
|
166
253
|
@property
|
167
254
|
def maximum_possible_bet_amount(self) -> USD:
|
168
|
-
return self.
|
255
|
+
return self.max_position_amount
|
169
256
|
|
170
257
|
@staticmethod
|
171
258
|
def calculate_direction(
|
@@ -196,11 +283,23 @@ class MultiCategoricalMaxAccuracyBettingStrategy(BettingStrategy):
|
|
196
283
|
market: AgentMarket,
|
197
284
|
) -> list[Trade]:
|
198
285
|
"""We place bet on only one outcome."""
|
199
|
-
|
200
286
|
outcome_to_bet_on = self.calculate_direction(market, answer)
|
201
287
|
|
288
|
+
# Will be lowered if the amount that we would need to buy would be unprofitable.
|
289
|
+
actual_wanted_position = BettingStrategy.cap_to_profitable_position(
|
290
|
+
market,
|
291
|
+
(
|
292
|
+
existing_position.amounts_current.get(outcome_to_bet_on, USD(0))
|
293
|
+
if existing_position
|
294
|
+
else USD(0)
|
295
|
+
),
|
296
|
+
self.max_position_amount,
|
297
|
+
outcome_to_bet_on,
|
298
|
+
)
|
299
|
+
|
202
300
|
target_position = Position(
|
203
|
-
market_id=market.id,
|
301
|
+
market_id=market.id,
|
302
|
+
amounts_current={outcome_to_bet_on: actual_wanted_position},
|
204
303
|
)
|
205
304
|
trades = self._build_rebalance_trades_from_positions(
|
206
305
|
existing_position=existing_position,
|
@@ -253,13 +352,19 @@ class MaxExpectedValueBettingStrategy(MultiCategoricalMaxAccuracyBettingStrategy
|
|
253
352
|
|
254
353
|
|
255
354
|
class KellyBettingStrategy(BettingStrategy):
|
256
|
-
def __init__(
|
257
|
-
self
|
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)
|
362
|
+
self.max_position_amount = max_position_amount
|
258
363
|
self.max_price_impact = max_price_impact
|
259
364
|
|
260
365
|
@property
|
261
366
|
def maximum_possible_bet_amount(self) -> USD:
|
262
|
-
return self.
|
367
|
+
return self.max_position_amount
|
263
368
|
|
264
369
|
@staticmethod
|
265
370
|
def get_kelly_bet(
|
@@ -321,7 +426,7 @@ class KellyBettingStrategy(BettingStrategy):
|
|
321
426
|
|
322
427
|
kelly_bet = self.get_kelly_bet(
|
323
428
|
market=market,
|
324
|
-
max_bet_amount=self.
|
429
|
+
max_bet_amount=self.max_position_amount,
|
325
430
|
direction=direction,
|
326
431
|
other_direction=other_direction,
|
327
432
|
answer=answer,
|
@@ -405,16 +510,21 @@ class KellyBettingStrategy(BettingStrategy):
|
|
405
510
|
return CollateralToken(optimized_bet_amount.x)
|
406
511
|
|
407
512
|
def __repr__(self) -> str:
|
408
|
-
return f"{self.__class__.__name__}(max_bet_amount={self.
|
513
|
+
return f"{self.__class__.__name__}(max_bet_amount={self.max_position_amount}, max_price_impact={self.max_price_impact})"
|
409
514
|
|
410
515
|
|
411
516
|
class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
412
|
-
def __init__(
|
413
|
-
self
|
517
|
+
def __init__(
|
518
|
+
self,
|
519
|
+
max_position_amount: USD,
|
520
|
+
take_profit: bool = True,
|
521
|
+
):
|
522
|
+
super().__init__(take_profit)
|
523
|
+
self.max_position_amount = max_position_amount
|
414
524
|
|
415
525
|
@property
|
416
526
|
def maximum_possible_bet_amount(self) -> USD:
|
417
|
-
return self.
|
527
|
+
return self.max_position_amount
|
418
528
|
|
419
529
|
def adjust_bet_amount(
|
420
530
|
self, existing_position: ExistingPosition | None, market: AgentMarket
|
@@ -422,7 +532,7 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
|
422
532
|
existing_position_total_amount = (
|
423
533
|
existing_position.total_amount_current if existing_position else USD(0)
|
424
534
|
)
|
425
|
-
return self.
|
535
|
+
return self.max_position_amount + existing_position_total_amount
|
426
536
|
|
427
537
|
def calculate_trades(
|
428
538
|
self,
|
@@ -471,4 +581,4 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
|
471
581
|
return trades
|
472
582
|
|
473
583
|
def __repr__(self) -> str:
|
474
|
-
return f"{self.__class__.__name__}(max_bet_amount={self.
|
584
|
+
return f"{self.__class__.__name__}(max_bet_amount={self.max_position_amount})"
|
@@ -93,7 +93,7 @@ class OmenJobAgentMarket(OmenAgentMarket, JobAgentMarket):
|
|
93
93
|
|
94
94
|
def get_job_trade(self, max_bond: USD, result: str) -> Trade:
|
95
95
|
# 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 = KellyBettingStrategy(
|
96
|
+
strategy = KellyBettingStrategy(max_position_amount=max_bond)
|
97
97
|
required_trades = strategy.calculate_trades(
|
98
98
|
existing_position=None,
|
99
99
|
answer=self.get_job_answer(result),
|
@@ -104,6 +104,7 @@ class OmenAgentMarket(AgentMarket):
|
|
104
104
|
|
105
105
|
collateral_token_contract_address_checksummed: ChecksumAddress
|
106
106
|
market_maker_contract_address_checksummed: ChecksumAddress
|
107
|
+
outcome_token_pool: dict[OutcomeStr, OutcomeToken]
|
107
108
|
condition: Condition
|
108
109
|
finalized_time: DatetimeUTC | None
|
109
110
|
created_time: DatetimeUTC
|
@@ -620,11 +621,10 @@ class OmenAgentMarket(AgentMarket):
|
|
620
621
|
Note: this is only valid if the market instance's token pool is
|
621
622
|
up-to-date with the smart contract.
|
622
623
|
"""
|
623
|
-
outcome_token_pool = check_not_none(self.outcome_token_pool)
|
624
624
|
amount = get_buy_outcome_token_amount(
|
625
625
|
investment_amount=self.get_in_token(bet_amount),
|
626
626
|
outcome_index=self.get_outcome_index(outcome),
|
627
|
-
pool_balances=[outcome_token_pool[x] for x in self.outcomes],
|
627
|
+
pool_balances=[self.outcome_token_pool[x] for x in self.outcomes],
|
628
628
|
fees=self.fees,
|
629
629
|
)
|
630
630
|
return amount
|
@@ -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 =
|
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:
|
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
|
-
|
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
|
-
|
419
|
+
t.Sequence[ChecksumAddress] | None
|
420
420
|
) = SAFE_COLLATERAL_TOKENS_ADDRESSES,
|
421
421
|
category: str | None = None,
|
422
422
|
include_categorical_markets: bool = True,
|
@@ -198,9 +198,7 @@ class SeerAgentMarket(AgentMarket):
|
|
198
198
|
)
|
199
199
|
)
|
200
200
|
|
201
|
-
amounts_ot[
|
202
|
-
OutcomeStr(outcome_str)
|
203
|
-
] = outcome_token_balance_wei.as_outcome_token
|
201
|
+
amounts_ot[outcome_str] = outcome_token_balance_wei.as_outcome_token
|
204
202
|
|
205
203
|
amounts_current = {
|
206
204
|
k: self.get_token_in_usd(self.get_sell_value_of_outcome_token(k, v))
|
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
|
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
|