prediction-market-agent-tooling 0.66.1__tar.gz → 0.66.2__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.2}/PKG-INFO +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/agent.py +3 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/betting_strategy.py +98 -15
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/omen.py +2 -2
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/seer/seer.py +1 -3
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/pyproject.toml +1 -1
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/README.md +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/gvp2_settlement.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/ownable.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/ownable_erc721.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/prediction_market_agent_tooling/abis/swapr_router.abi.json +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/chains.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/deploy/trade_interval.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/logprobs_parser.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/agent_market.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/base_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/blockchain_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/market_fees.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/cow_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/omen_constants.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/polymarket/api.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/seer/data_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/seer/exceptions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/seer/price_manager.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/markets/seer/seer_contracts.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/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.2}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/_generic_value.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/caches/db_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/caches/inmemory_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/caches/serializers.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/cow/cow_order.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/cow/models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/cow/semaphore.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/custom_exceptions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/datetime_utc.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/db/db_manager.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/google_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/httpx_cached_client.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/is_invalid.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/is_predictable.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/omen/sell_positions.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_client.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/perplexity/perplexity_search.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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.2}/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.2}/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.2}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tavily/tavily_models.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tavily/tavily_search.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tokens/auto_deposit.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tokens/auto_withdraw.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tokens/main_token.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tokens/token_utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/tokens/usd.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/transaction_cache.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.66.1 → prediction_market_agent_tooling-0.66.2}/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
|
@@ -94,6 +95,76 @@ class BettingStrategy(ABC):
|
|
94
95
|
)
|
95
96
|
return trades
|
96
97
|
|
98
|
+
@staticmethod
|
99
|
+
def cap_to_profitable_bet_amount(
|
100
|
+
market: AgentMarket,
|
101
|
+
bet_amount: USD,
|
102
|
+
outcome: OutcomeStr,
|
103
|
+
iters: int = 10,
|
104
|
+
) -> USD:
|
105
|
+
"""
|
106
|
+
Use a binary search (tree-based search) to efficiently find the largest profitable bet amount.
|
107
|
+
"""
|
108
|
+
# First, try it with the desired amount right away.
|
109
|
+
if (
|
110
|
+
market.get_in_usd(
|
111
|
+
check_not_none(
|
112
|
+
market.get_buy_token_amount(bet_amount, outcome)
|
113
|
+
).as_token
|
114
|
+
)
|
115
|
+
> bet_amount
|
116
|
+
):
|
117
|
+
return bet_amount
|
118
|
+
|
119
|
+
# If it wasn't profitable, try binary search to find the highest, but profitable, amount.
|
120
|
+
lower = USD(0)
|
121
|
+
# It doesn't make sense to try to bet more than the liquidity itself, so override it as maximal value if it's lower.
|
122
|
+
upper = min(bet_amount, market.get_in_usd(market.get_liquidity()))
|
123
|
+
best_profitable = USD(0)
|
124
|
+
|
125
|
+
for _ in range(iters):
|
126
|
+
mid = (lower + upper) / 2
|
127
|
+
potential_outcome_value = market.get_in_usd(
|
128
|
+
check_not_none(market.get_buy_token_amount(mid, outcome)).as_token
|
129
|
+
)
|
130
|
+
|
131
|
+
if potential_outcome_value > mid:
|
132
|
+
# Profitable, try higher
|
133
|
+
best_profitable = mid
|
134
|
+
lower = mid
|
135
|
+
|
136
|
+
else:
|
137
|
+
# Not profitable, try lower
|
138
|
+
upper = mid
|
139
|
+
|
140
|
+
# If the search interval is very small, break early
|
141
|
+
if float(upper - lower) < 1e-8:
|
142
|
+
break
|
143
|
+
|
144
|
+
if np.isclose(best_profitable.value, 0):
|
145
|
+
best_profitable = USD(0)
|
146
|
+
|
147
|
+
return best_profitable
|
148
|
+
|
149
|
+
@staticmethod
|
150
|
+
def cap_to_profitable_position(
|
151
|
+
market: AgentMarket,
|
152
|
+
existing_position: USD,
|
153
|
+
wanted_position: USD,
|
154
|
+
outcome_to_bet_on: OutcomeStr,
|
155
|
+
) -> USD:
|
156
|
+
# If the wanted position is lower, it means the agent is gonna sell and that's profitable always.
|
157
|
+
if wanted_position > existing_position:
|
158
|
+
difference = wanted_position - existing_position
|
159
|
+
# Cap the difference we would like to buy to a profitable one.
|
160
|
+
capped_difference = BettingStrategy.cap_to_profitable_bet_amount(
|
161
|
+
market, difference, outcome_to_bet_on
|
162
|
+
)
|
163
|
+
# Lowered the actual wanted position such that it remains profitable.
|
164
|
+
wanted_position = existing_position + capped_difference
|
165
|
+
|
166
|
+
return wanted_position
|
167
|
+
|
97
168
|
def _build_rebalance_trades_from_positions(
|
98
169
|
self,
|
99
170
|
existing_position: ExistingPosition | None,
|
@@ -160,12 +231,12 @@ class BettingStrategy(ABC):
|
|
160
231
|
|
161
232
|
|
162
233
|
class MultiCategoricalMaxAccuracyBettingStrategy(BettingStrategy):
|
163
|
-
def __init__(self,
|
164
|
-
self.
|
234
|
+
def __init__(self, max_position_amount: USD):
|
235
|
+
self.max_position_amount = max_position_amount
|
165
236
|
|
166
237
|
@property
|
167
238
|
def maximum_possible_bet_amount(self) -> USD:
|
168
|
-
return self.
|
239
|
+
return self.max_position_amount
|
169
240
|
|
170
241
|
@staticmethod
|
171
242
|
def calculate_direction(
|
@@ -196,11 +267,23 @@ class MultiCategoricalMaxAccuracyBettingStrategy(BettingStrategy):
|
|
196
267
|
market: AgentMarket,
|
197
268
|
) -> list[Trade]:
|
198
269
|
"""We place bet on only one outcome."""
|
199
|
-
|
200
270
|
outcome_to_bet_on = self.calculate_direction(market, answer)
|
201
271
|
|
272
|
+
# Will be lowered if the amount that we would need to buy would be unprofitable.
|
273
|
+
actual_wanted_position = BettingStrategy.cap_to_profitable_position(
|
274
|
+
market,
|
275
|
+
(
|
276
|
+
existing_position.amounts_current.get(outcome_to_bet_on, USD(0))
|
277
|
+
if existing_position
|
278
|
+
else USD(0)
|
279
|
+
),
|
280
|
+
self.max_position_amount,
|
281
|
+
outcome_to_bet_on,
|
282
|
+
)
|
283
|
+
|
202
284
|
target_position = Position(
|
203
|
-
market_id=market.id,
|
285
|
+
market_id=market.id,
|
286
|
+
amounts_current={outcome_to_bet_on: actual_wanted_position},
|
204
287
|
)
|
205
288
|
trades = self._build_rebalance_trades_from_positions(
|
206
289
|
existing_position=existing_position,
|
@@ -253,13 +336,13 @@ class MaxExpectedValueBettingStrategy(MultiCategoricalMaxAccuracyBettingStrategy
|
|
253
336
|
|
254
337
|
|
255
338
|
class KellyBettingStrategy(BettingStrategy):
|
256
|
-
def __init__(self,
|
257
|
-
self.
|
339
|
+
def __init__(self, max_position_amount: USD, max_price_impact: float | None = None):
|
340
|
+
self.max_position_amount = max_position_amount
|
258
341
|
self.max_price_impact = max_price_impact
|
259
342
|
|
260
343
|
@property
|
261
344
|
def maximum_possible_bet_amount(self) -> USD:
|
262
|
-
return self.
|
345
|
+
return self.max_position_amount
|
263
346
|
|
264
347
|
@staticmethod
|
265
348
|
def get_kelly_bet(
|
@@ -321,7 +404,7 @@ class KellyBettingStrategy(BettingStrategy):
|
|
321
404
|
|
322
405
|
kelly_bet = self.get_kelly_bet(
|
323
406
|
market=market,
|
324
|
-
max_bet_amount=self.
|
407
|
+
max_bet_amount=self.max_position_amount,
|
325
408
|
direction=direction,
|
326
409
|
other_direction=other_direction,
|
327
410
|
answer=answer,
|
@@ -405,16 +488,16 @@ class KellyBettingStrategy(BettingStrategy):
|
|
405
488
|
return CollateralToken(optimized_bet_amount.x)
|
406
489
|
|
407
490
|
def __repr__(self) -> str:
|
408
|
-
return f"{self.__class__.__name__}(max_bet_amount={self.
|
491
|
+
return f"{self.__class__.__name__}(max_bet_amount={self.max_position_amount}, max_price_impact={self.max_price_impact})"
|
409
492
|
|
410
493
|
|
411
494
|
class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
412
|
-
def __init__(self,
|
413
|
-
self.
|
495
|
+
def __init__(self, max_position_amount: USD):
|
496
|
+
self.max_position_amount = max_position_amount
|
414
497
|
|
415
498
|
@property
|
416
499
|
def maximum_possible_bet_amount(self) -> USD:
|
417
|
-
return self.
|
500
|
+
return self.max_position_amount
|
418
501
|
|
419
502
|
def adjust_bet_amount(
|
420
503
|
self, existing_position: ExistingPosition | None, market: AgentMarket
|
@@ -422,7 +505,7 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
|
422
505
|
existing_position_total_amount = (
|
423
506
|
existing_position.total_amount_current if existing_position else USD(0)
|
424
507
|
)
|
425
|
-
return self.
|
508
|
+
return self.max_position_amount + existing_position_total_amount
|
426
509
|
|
427
510
|
def calculate_trades(
|
428
511
|
self,
|
@@ -471,4 +554,4 @@ class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
|
471
554
|
return trades
|
472
555
|
|
473
556
|
def __repr__(self) -> str:
|
474
|
-
return f"{self.__class__.__name__}(max_bet_amount={self.
|
557
|
+
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
|
@@ -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
|
File without changes
|