prediction-market-agent-tooling 0.49.1__tar.gz → 0.49.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.49.1 → prediction_market_agent_tooling-0.49.2}/PKG-INFO +2 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/agent.py +1 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/betting_strategy.py +83 -3
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/agent_market.py +2 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/omen.py +2 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/omen_contracts.py +1 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/omen_resolving.py +1 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +10 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/polymarket/api.py +1 -1
- prediction_market_agent_tooling-0.49.2/prediction_market_agent_tooling/tools/httpx_cached_client.py +11 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/is_predictable.py +1 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/tavily_storage/tavily_models.py +1 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/pyproject.toml +2 -1
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/README.md +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/debuggingcontract.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/depositablewrapper_erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/erc20.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/erc4626.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_agentresultmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_dxdao.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_fpmm.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_fpmm_conditionaltokens.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_fpmm_factory.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_kleros.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_oracle.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_realitio.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/omen_thumbnailmapping.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/abis/proxy.abi.json +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/benchmark/__init__.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/benchmark/agents.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/benchmark/benchmark.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/benchmark/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/config.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/agent_example.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/constants.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/gcp/deploy.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/deploy/gcp/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/gtypes.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/jobs/__init__.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/jobs/jobs.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/jobs/jobs_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/jobs/omen/omen_jobs.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/loggers.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/categorize.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/data_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/manifold/__init__.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/manifold/api.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/manifold/data_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/manifold/manifold.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/manifold/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/markets.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/metaculus/api.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/metaculus/data_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/metaculus/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/__init__.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/omen/data_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/polymarket/data_models.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/polymarket/data_models_web.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/polymarket/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/markets/polymarket/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/markets/manifold.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/markets/omen.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/monitor.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/monitor_app.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/monitor/monitor_settings.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/py.typed +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/balances.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/betting_strategies/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/cache.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/contract.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/costs.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/gnosis_rpc.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/google.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/hexbytes_custom.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/image_gen/image_gen.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/langfuse_.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/langfuse_client_utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/omen/reality_accuracy.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/parallelism.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/safe.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/singleton.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/streamlit_user_login.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/tavily_storage/tavily_storage.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/utils.py +0 -0
- {prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/prediction_market_agent_tooling/tools/web3_utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: prediction-market-agent-tooling
|
3
|
-
Version: 0.49.
|
3
|
+
Version: 0.49.2
|
4
4
|
Summary: Tools to benchmark, deploy and monitor prediction market agents.
|
5
5
|
Author: Gnosis
|
6
6
|
Requires-Python: >=3.10,<3.12
|
@@ -20,6 +20,7 @@ Requires-Dist: google-api-python-client (==2.95.0) ; extra == "google"
|
|
20
20
|
Requires-Dist: google-cloud-functions (>=1.16.0,<2.0.0)
|
21
21
|
Requires-Dist: google-cloud-resource-manager (>=1.12.0,<2.0.0)
|
22
22
|
Requires-Dist: google-cloud-secret-manager (>=2.18.2,<3.0.0)
|
23
|
+
Requires-Dist: hishel (>=0.0.31,<0.0.32)
|
23
24
|
Requires-Dist: isort (>=5.13.2,<6.0.0)
|
24
25
|
Requires-Dist: langchain (>=0.2.6,<0.3.0) ; extra == "langchain"
|
25
26
|
Requires-Dist: langchain-community (>=0.0.19)
|
@@ -307,7 +307,7 @@ class DeployableTraderAgent(DeployableAgent):
|
|
307
307
|
def get_betting_strategy(self, market: AgentMarket) -> BettingStrategy:
|
308
308
|
user_id = market.get_user_id(api_keys=APIKeys())
|
309
309
|
|
310
|
-
total_amount = market.
|
310
|
+
total_amount = market.get_tiny_bet_amount().amount
|
311
311
|
if existing_position := market.get_position(user_id=user_id):
|
312
312
|
total_amount += existing_position.total_amount.amount
|
313
313
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
from abc import ABC, abstractmethod
|
2
2
|
|
3
|
+
from scipy.optimize import minimize_scalar
|
4
|
+
|
5
|
+
from prediction_market_agent_tooling.gtypes import xDai
|
6
|
+
from prediction_market_agent_tooling.loggers import logger
|
3
7
|
from prediction_market_agent_tooling.markets.agent_market import AgentMarket
|
4
8
|
from prediction_market_agent_tooling.markets.data_models import (
|
5
9
|
Currency,
|
@@ -10,10 +14,14 @@ from prediction_market_agent_tooling.markets.data_models import (
|
|
10
14
|
TradeType,
|
11
15
|
)
|
12
16
|
from prediction_market_agent_tooling.markets.omen.data_models import get_boolean_outcome
|
17
|
+
from prediction_market_agent_tooling.markets.omen.omen import (
|
18
|
+
get_buy_outcome_token_amount,
|
19
|
+
)
|
13
20
|
from prediction_market_agent_tooling.tools.betting_strategies.kelly_criterion import (
|
14
21
|
get_kelly_bet_full,
|
15
22
|
get_kelly_bet_simplified,
|
16
23
|
)
|
24
|
+
from prediction_market_agent_tooling.tools.betting_strategies.utils import SimpleBet
|
17
25
|
from prediction_market_agent_tooling.tools.utils import check_not_none
|
18
26
|
|
19
27
|
|
@@ -134,8 +142,9 @@ class MaxExpectedValueBettingStrategy(MaxAccuracyBettingStrategy):
|
|
134
142
|
|
135
143
|
|
136
144
|
class KellyBettingStrategy(BettingStrategy):
|
137
|
-
def __init__(self, max_bet_amount: float):
|
145
|
+
def __init__(self, max_bet_amount: float, max_price_impact: float | None = None):
|
138
146
|
self.max_bet_amount = max_bet_amount
|
147
|
+
self.max_price_impact = max_price_impact
|
139
148
|
|
140
149
|
def calculate_trades(
|
141
150
|
self,
|
@@ -165,9 +174,19 @@ class KellyBettingStrategy(BettingStrategy):
|
|
165
174
|
)
|
166
175
|
)
|
167
176
|
|
177
|
+
kelly_bet_size = kelly_bet.size
|
178
|
+
if self.max_price_impact:
|
179
|
+
# Adjust amount
|
180
|
+
max_price_impact_bet_amount = self.calculate_bet_amount_for_price_impact(
|
181
|
+
market, kelly_bet, 0
|
182
|
+
)
|
183
|
+
|
184
|
+
# We just don't want Kelly size to extrapolate price_impact - hence we take the min.
|
185
|
+
kelly_bet_size = min(kelly_bet.size, max_price_impact_bet_amount)
|
186
|
+
|
168
187
|
amounts = {
|
169
188
|
market.get_outcome_str_from_bool(kelly_bet.direction): TokenAmount(
|
170
|
-
amount=
|
189
|
+
amount=kelly_bet_size, currency=market.currency
|
171
190
|
),
|
172
191
|
}
|
173
192
|
target_position = Position(market_id=market.id, amounts=amounts)
|
@@ -176,8 +195,69 @@ class KellyBettingStrategy(BettingStrategy):
|
|
176
195
|
)
|
177
196
|
return trades
|
178
197
|
|
198
|
+
def calculate_price_impact_for_bet_amount(
|
199
|
+
self, buy_direction: bool, bet_amount: float, yes: float, no: float, fee: float
|
200
|
+
) -> float:
|
201
|
+
total_outcome_tokens = yes + no
|
202
|
+
expected_price = (
|
203
|
+
no / total_outcome_tokens if buy_direction else yes / total_outcome_tokens
|
204
|
+
)
|
205
|
+
|
206
|
+
tokens_to_buy = get_buy_outcome_token_amount(
|
207
|
+
bet_amount, buy_direction, yes, no, fee
|
208
|
+
)
|
209
|
+
|
210
|
+
actual_price = bet_amount / tokens_to_buy
|
211
|
+
# price_impact should always be > 0
|
212
|
+
price_impact = (actual_price - expected_price) / expected_price
|
213
|
+
return price_impact
|
214
|
+
|
215
|
+
def calculate_bet_amount_for_price_impact(
|
216
|
+
self,
|
217
|
+
market: AgentMarket,
|
218
|
+
kelly_bet: SimpleBet,
|
219
|
+
fee: float,
|
220
|
+
) -> float:
|
221
|
+
def calculate_price_impact_deviation_from_target_price_impact(
|
222
|
+
bet_amount: xDai,
|
223
|
+
) -> float:
|
224
|
+
price_impact = self.calculate_price_impact_for_bet_amount(
|
225
|
+
kelly_bet.direction,
|
226
|
+
bet_amount,
|
227
|
+
yes_outcome_pool_size,
|
228
|
+
no_outcome_pool_size,
|
229
|
+
fee,
|
230
|
+
)
|
231
|
+
# We return abs for the algorithm to converge to 0 instead of the min (and possibly negative) value.
|
232
|
+
|
233
|
+
max_price_impact = check_not_none(self.max_price_impact)
|
234
|
+
return abs(price_impact - max_price_impact)
|
235
|
+
|
236
|
+
if not market.outcome_token_pool:
|
237
|
+
logger.warning(
|
238
|
+
"Market outcome_token_pool is None, cannot calculate bet amount"
|
239
|
+
)
|
240
|
+
return kelly_bet.size
|
241
|
+
|
242
|
+
yes_outcome_pool_size = market.outcome_token_pool[
|
243
|
+
market.get_outcome_str_from_bool(True)
|
244
|
+
]
|
245
|
+
no_outcome_pool_size = market.outcome_token_pool[
|
246
|
+
market.get_outcome_str_from_bool(False)
|
247
|
+
]
|
248
|
+
|
249
|
+
# The bounds below have been found to work heuristically.
|
250
|
+
optimized_bet_amount = minimize_scalar(
|
251
|
+
calculate_price_impact_deviation_from_target_price_impact,
|
252
|
+
bounds=(0, 1000 * (yes_outcome_pool_size + no_outcome_pool_size)),
|
253
|
+
method="bounded",
|
254
|
+
tol=1e-11,
|
255
|
+
options={"maxiter": 10000},
|
256
|
+
)
|
257
|
+
return float(optimized_bet_amount.x)
|
258
|
+
|
179
259
|
def __repr__(self) -> str:
|
180
|
-
return f"{self.__class__.__name__}(max_bet_amount={self.max_bet_amount})"
|
260
|
+
return f"{self.__class__.__name__}(max_bet_amount={self.max_bet_amount}, max_price_impact={self.max_price_impact})"
|
181
261
|
|
182
262
|
|
183
263
|
class MaxAccuracyWithKellyScaledBetsStrategy(BettingStrategy):
|
@@ -47,6 +47,7 @@ from prediction_market_agent_tooling.markets.omen.data_models import (
|
|
47
47
|
)
|
48
48
|
from prediction_market_agent_tooling.markets.omen.omen_contracts import (
|
49
49
|
OMEN_DEFAULT_MARKET_FEE_PERC,
|
50
|
+
REALITY_DEFAULT_FINALIZATION_TIMEOUT,
|
50
51
|
Arbitrator,
|
51
52
|
OmenConditionalTokenContract,
|
52
53
|
OmenFixedProductMarketMakerContract,
|
@@ -840,7 +841,7 @@ def omen_create_market_tx(
|
|
840
841
|
language: str,
|
841
842
|
outcomes: list[str],
|
842
843
|
auto_deposit: bool,
|
843
|
-
finalization_timeout: timedelta =
|
844
|
+
finalization_timeout: timedelta = REALITY_DEFAULT_FINALIZATION_TIMEOUT,
|
844
845
|
fee_perc: float = OMEN_DEFAULT_MARKET_FEE_PERC,
|
845
846
|
distribution_hint: list[OmenOutcomeToken] | None = None,
|
846
847
|
collateral_token_address: ChecksumAddress = WrappedxDaiContract().address,
|
@@ -431,6 +431,7 @@ class sDaiContract(ContractERC4626OnGnosisChain):
|
|
431
431
|
|
432
432
|
|
433
433
|
OMEN_DEFAULT_MARKET_FEE_PERC = 0.02 # 2% fee from the buying shares amount.
|
434
|
+
REALITY_DEFAULT_FINALIZATION_TIMEOUT = timedelta(days=3)
|
434
435
|
|
435
436
|
|
436
437
|
class OmenFixedProductMarketMakerFactoryContract(ContractOnGnosisChain):
|
@@ -240,7 +240,7 @@ def omen_resolve_market_tx(
|
|
240
240
|
web3: Web3 | None = None,
|
241
241
|
) -> None:
|
242
242
|
"""
|
243
|
-
Market can be resolved
|
243
|
+
Market can be resolved after the answer if finalized on Reality.
|
244
244
|
"""
|
245
245
|
oracle_contract = OmenOracleContract()
|
246
246
|
oracle_contract.resolve(
|
@@ -319,6 +319,16 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
319
319
|
sort_by_field = (
|
320
320
|
self.trades_subgraph.FixedProductMarketMaker.openingTimestamp
|
321
321
|
)
|
322
|
+
case SortBy.HIGHEST_LIQUIDITY:
|
323
|
+
sort_direction = "desc"
|
324
|
+
sort_by_field = (
|
325
|
+
self.trades_subgraph.FixedProductMarketMaker.liquidityMeasure
|
326
|
+
)
|
327
|
+
case SortBy.LOWEST_LIQUIDITY:
|
328
|
+
sort_direction = "asc"
|
329
|
+
sort_by_field = (
|
330
|
+
self.trades_subgraph.FixedProductMarketMaker.liquidityMeasure
|
331
|
+
)
|
322
332
|
case SortBy.NONE:
|
323
333
|
sort_direction = None
|
324
334
|
sort_by_field = None
|
@@ -2,8 +2,8 @@ import typing as t
|
|
2
2
|
|
3
3
|
import requests
|
4
4
|
import tenacity
|
5
|
-
from loguru import logger
|
6
5
|
|
6
|
+
from prediction_market_agent_tooling.loggers import logger
|
7
7
|
from prediction_market_agent_tooling.markets.polymarket.data_models import (
|
8
8
|
POLYMARKET_FALSE_OUTCOME,
|
9
9
|
POLYMARKET_TRUE_OUTCOME,
|
prediction_market_agent_tooling-0.49.2/prediction_market_agent_tooling/tools/httpx_cached_client.py
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
import hishel
|
2
|
+
|
3
|
+
|
4
|
+
class HttpxCachedClient:
|
5
|
+
def __init__(self) -> None:
|
6
|
+
storage = hishel.FileStorage(ttl=3600, check_ttl_every=600)
|
7
|
+
controller = hishel.Controller(force_cache=True)
|
8
|
+
self.client = hishel.CacheClient(storage=storage, controller=controller)
|
9
|
+
|
10
|
+
def get_client(self) -> hishel.CacheClient:
|
11
|
+
return self.client
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import tenacity
|
2
|
-
from loguru import logger
|
3
2
|
|
4
3
|
from prediction_market_agent_tooling.config import APIKeys
|
4
|
+
from prediction_market_agent_tooling.loggers import logger
|
5
5
|
from prediction_market_agent_tooling.tools.cache import persistent_inmemory_cache
|
6
6
|
from prediction_market_agent_tooling.tools.langfuse_ import (
|
7
7
|
get_langfuse_langchain_config,
|
@@ -2,7 +2,6 @@ import typing as t
|
|
2
2
|
from datetime import datetime, timedelta
|
3
3
|
|
4
4
|
import tenacity
|
5
|
-
from loguru import logger
|
6
5
|
from pydantic import BaseModel
|
7
6
|
from sqlalchemy import Column
|
8
7
|
from sqlalchemy.dialects.postgresql import JSONB
|
@@ -18,6 +17,7 @@ from sqlmodel import (
|
|
18
17
|
)
|
19
18
|
|
20
19
|
from prediction_market_agent_tooling.config import APIKeys
|
20
|
+
from prediction_market_agent_tooling.loggers import logger
|
21
21
|
from prediction_market_agent_tooling.tools.utils import utcnow
|
22
22
|
|
23
23
|
|
{prediction_market_agent_tooling-0.49.1 → prediction_market_agent_tooling-0.49.2}/pyproject.toml
RENAMED
@@ -1,6 +1,6 @@
|
|
1
1
|
[tool.poetry]
|
2
2
|
name = "prediction-market-agent-tooling"
|
3
|
-
version = "0.49.
|
3
|
+
version = "0.49.2"
|
4
4
|
description = "Tools to benchmark, deploy and monitor prediction market agents."
|
5
5
|
authors = ["Gnosis"]
|
6
6
|
readme = "README.md"
|
@@ -49,6 +49,7 @@ psycopg2-binary = "^2.9.9"
|
|
49
49
|
base58 = ">=1.0.2,<2.0"
|
50
50
|
loky = "^3.4.1"
|
51
51
|
pinatapy-vourhey = "^0.2.0"
|
52
|
+
hishel = "^0.0.31"
|
52
53
|
|
53
54
|
[tool.poetry.extras]
|
54
55
|
openai = ["openai"]
|
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
|