prediction-market-agent-tooling 0.18.0__py3-none-any.whl → 0.20.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- prediction_market_agent_tooling/deploy/agent.py +29 -4
- prediction_market_agent_tooling/markets/markets.py +43 -1
- prediction_market_agent_tooling/tools/balances.py +1 -1
- {prediction_market_agent_tooling-0.18.0.dist-info → prediction_market_agent_tooling-0.20.0.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.18.0.dist-info → prediction_market_agent_tooling-0.20.0.dist-info}/RECORD +8 -8
- {prediction_market_agent_tooling-0.18.0.dist-info → prediction_market_agent_tooling-0.20.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.18.0.dist-info → prediction_market_agent_tooling-0.20.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.18.0.dist-info → prediction_market_agent_tooling-0.20.0.dist-info}/entry_points.txt +0 -0
@@ -3,7 +3,7 @@ import os
|
|
3
3
|
import tempfile
|
4
4
|
import time
|
5
5
|
import typing as t
|
6
|
-
from datetime import datetime
|
6
|
+
from datetime import datetime, timedelta
|
7
7
|
|
8
8
|
from loguru import logger
|
9
9
|
from pydantic import BaseModel, BeforeValidator
|
@@ -30,7 +30,10 @@ from prediction_market_agent_tooling.markets.agent_market import (
|
|
30
30
|
SortBy,
|
31
31
|
)
|
32
32
|
from prediction_market_agent_tooling.markets.data_models import BetAmount
|
33
|
-
from prediction_market_agent_tooling.markets.markets import
|
33
|
+
from prediction_market_agent_tooling.markets.markets import (
|
34
|
+
MarketType,
|
35
|
+
have_bet_on_market_since,
|
36
|
+
)
|
34
37
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
35
38
|
redeem_from_all_user_positions,
|
36
39
|
)
|
@@ -40,6 +43,7 @@ from prediction_market_agent_tooling.monitor.langfuse.langfuse_wrapper import (
|
|
40
43
|
from prediction_market_agent_tooling.monitor.monitor_app import (
|
41
44
|
MARKET_TYPE_TO_DEPLOYED_AGENT,
|
42
45
|
)
|
46
|
+
from prediction_market_agent_tooling.tools.is_predictable import is_predictable_binary
|
43
47
|
from prediction_market_agent_tooling.tools.utils import DatetimeWithTimezone, utcnow
|
44
48
|
|
45
49
|
MAX_AVAILABLE_MARKETS = 20
|
@@ -80,6 +84,8 @@ class Answer(BaseModel):
|
|
80
84
|
|
81
85
|
|
82
86
|
class DeployableAgent:
|
87
|
+
bet_on_n_markets_per_run: int = 1
|
88
|
+
|
83
89
|
def __init__(self) -> None:
|
84
90
|
self.langfuse_wrapper = LangfuseWrapper(agent_name=self.__class__.__name__)
|
85
91
|
self.load()
|
@@ -93,11 +99,30 @@ class DeployableAgent:
|
|
93
99
|
def load(self) -> None:
|
94
100
|
pass
|
95
101
|
|
102
|
+
def have_bet_on_market_since(self, market: AgentMarket, since: timedelta) -> bool:
|
103
|
+
return have_bet_on_market_since(keys=APIKeys(), market=market, since=since)
|
104
|
+
|
96
105
|
def pick_markets(self, markets: t.Sequence[AgentMarket]) -> t.Sequence[AgentMarket]:
|
97
106
|
"""
|
98
|
-
|
107
|
+
Subclasses can implement their own logic instead of this one, or on top of this one.
|
108
|
+
By default, it picks only the first {n_markets_per_run} markets where user didn't bet recently and it's a reasonable question.
|
99
109
|
"""
|
100
|
-
|
110
|
+
picked: list[AgentMarket] = []
|
111
|
+
|
112
|
+
for market in markets:
|
113
|
+
if len(picked) >= self.bet_on_n_markets_per_run:
|
114
|
+
break
|
115
|
+
|
116
|
+
if self.have_bet_on_market_since(market, since=timedelta(hours=24)):
|
117
|
+
continue
|
118
|
+
|
119
|
+
# Do as a last check, as it uses paid OpenAI API.
|
120
|
+
if not is_predictable_binary(market.question):
|
121
|
+
continue
|
122
|
+
|
123
|
+
picked.append(market)
|
124
|
+
|
125
|
+
return picked
|
101
126
|
|
102
127
|
def answer_binary_market(self, market: AgentMarket) -> Answer | None:
|
103
128
|
"""
|
@@ -1,19 +1,29 @@
|
|
1
1
|
import typing as t
|
2
|
-
from datetime import datetime
|
2
|
+
from datetime import datetime, timedelta
|
3
3
|
from enum import Enum
|
4
4
|
|
5
|
+
from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
|
5
6
|
from prediction_market_agent_tooling.markets.agent_market import (
|
6
7
|
AgentMarket,
|
7
8
|
FilterBy,
|
8
9
|
SortBy,
|
9
10
|
)
|
11
|
+
from prediction_market_agent_tooling.markets.manifold.api import (
|
12
|
+
get_authenticated_user,
|
13
|
+
get_manifold_bets,
|
14
|
+
get_manifold_market,
|
15
|
+
)
|
10
16
|
from prediction_market_agent_tooling.markets.manifold.manifold import (
|
11
17
|
ManifoldAgentMarket,
|
12
18
|
)
|
13
19
|
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
|
20
|
+
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
21
|
+
OmenSubgraphHandler,
|
22
|
+
)
|
14
23
|
from prediction_market_agent_tooling.markets.polymarket.polymarket import (
|
15
24
|
PolymarketAgentMarket,
|
16
25
|
)
|
26
|
+
from prediction_market_agent_tooling.tools.utils import should_not_happen, utcnow
|
17
27
|
|
18
28
|
|
19
29
|
class MarketType(str, Enum):
|
@@ -52,3 +62,35 @@ def get_binary_markets(
|
|
52
62
|
excluded_questions=excluded_questions,
|
53
63
|
)
|
54
64
|
return markets
|
65
|
+
|
66
|
+
|
67
|
+
def have_bet_on_market_since(
|
68
|
+
keys: APIKeys, market: AgentMarket, since: timedelta
|
69
|
+
) -> bool:
|
70
|
+
start_time = utcnow() - since
|
71
|
+
credentials = PrivateCredentials.from_api_keys(keys)
|
72
|
+
recently_betted_questions = (
|
73
|
+
set(
|
74
|
+
get_manifold_market(b.contractId).question
|
75
|
+
for b in get_manifold_bets(
|
76
|
+
user_id=get_authenticated_user(
|
77
|
+
keys.manifold_api_key.get_secret_value()
|
78
|
+
).id,
|
79
|
+
start_time=start_time,
|
80
|
+
end_time=None,
|
81
|
+
)
|
82
|
+
)
|
83
|
+
if isinstance(market, ManifoldAgentMarket)
|
84
|
+
else (
|
85
|
+
set(
|
86
|
+
b.title
|
87
|
+
for b in OmenSubgraphHandler().get_bets(
|
88
|
+
better_address=credentials.public_key,
|
89
|
+
start_time=start_time,
|
90
|
+
)
|
91
|
+
)
|
92
|
+
if isinstance(market, OmenAgentMarket)
|
93
|
+
else should_not_happen(f"Uknown market: {market}")
|
94
|
+
)
|
95
|
+
)
|
96
|
+
return market.question in recently_betted_questions
|
@@ -14,7 +14,7 @@ class Balances(BaseModel):
|
|
14
14
|
wxdai: xDai
|
15
15
|
|
16
16
|
|
17
|
-
def get_balances(address: ChecksumAddress, web3: Web3 | None) -> Balances:
|
17
|
+
def get_balances(address: ChecksumAddress, web3: Web3 | None = None) -> Balances:
|
18
18
|
if not web3:
|
19
19
|
web3 = WrappedxDaiContract().get_web3()
|
20
20
|
xdai_balance = Wei(web3.eth.get_balance(address))
|
@@ -12,7 +12,7 @@ prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3Ukktb
|
|
12
12
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
|
13
13
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=iS1BzyXcCMfMm1Rx--1QCH0pHvBTblTndcDQFbTUJ2s,2897
|
14
14
|
prediction_market_agent_tooling/config.py,sha256=FI8feNLmA0QYmN-llvyDh3c6tN2ZGl7Eerw1e27v51A,4757
|
15
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
15
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=aXlrfOymjvLdpxgF88XsFBsPnCG0Q3-EqreV1WYqxro,9985
|
16
16
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=KaTJm43cwbBZR2BmTEyB1ohChAqwYlBUqaaVumsWQe4,891
|
17
17
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
18
18
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
@@ -27,7 +27,7 @@ prediction_market_agent_tooling/markets/manifold/api.py,sha256=K79zWSqBs3rpkZwpp
|
|
27
27
|
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=2DZIxwtDp-PH0UWTGiktMFIGAAQoVutI07UsxjNyTyE,5296
|
28
28
|
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=DJZ88r5BGtAugUw5SIyDfzK1S70titba_fwT7OYXuAY,3896
|
29
29
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=cPPFWXm3vCYH1jy7_ctJZuQH9ZDaPL4_AgAYzGWkoow,513
|
30
|
-
prediction_market_agent_tooling/markets/markets.py,sha256=
|
30
|
+
prediction_market_agent_tooling/markets/markets.py,sha256=TXo2qNmjUXhbTK0d-V7hW_aaJDpqP9RWHxm7mayhI0o,3042
|
31
31
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
32
32
|
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=g6A_DQ54m-_3XQO02AM4NliDycsgYvg8hgpt8Dri5cg,14111
|
33
33
|
prediction_market_agent_tooling/markets/omen/omen.py,sha256=TbyZ39rcMsM1xpsW1CtHJSKBN3CIufN-O0RwGKW1IyQ,31823
|
@@ -47,7 +47,7 @@ prediction_market_agent_tooling/monitor/monitor.py,sha256=zTluK6Ha_pis6JWd8SF8Pb
|
|
47
47
|
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=rDxgdDJqSK0ARx0TJFMkS76npkHZJz0__Rp0xTpiRok,4611
|
48
48
|
prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
|
49
49
|
prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
50
|
-
prediction_market_agent_tooling/tools/balances.py,sha256=
|
50
|
+
prediction_market_agent_tooling/tools/balances.py,sha256=efDKEe-SsuSmGWKuGNiuHEWCGuCrcwjrCdTz1iKFtqw,749
|
51
51
|
prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py,sha256=IbhQPoKsQnjnag_n_wAL12n8QdCe7tAMRNV2QS8yYxY,3520
|
52
52
|
prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256=0qPFA0hNzgUKt49xovwwFaSYrunFgpWZ0Di1Lo3g5qw,4367
|
53
53
|
prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
|
@@ -64,8 +64,8 @@ prediction_market_agent_tooling/tools/safe.py,sha256=gNgcY6ugckx3DbupR8VBezDgh1d
|
|
64
64
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
65
65
|
prediction_market_agent_tooling/tools/utils.py,sha256=6MRfLr5xGPEQGobLz_eCsE_p-XaAeOCcmygwgNCIvqE,5044
|
66
66
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=-IAt12kudrx0BaW_IFQu2nAsJJXVGn8hNH43xjQeIw4,9822
|
67
|
-
prediction_market_agent_tooling-0.
|
68
|
-
prediction_market_agent_tooling-0.
|
69
|
-
prediction_market_agent_tooling-0.
|
70
|
-
prediction_market_agent_tooling-0.
|
71
|
-
prediction_market_agent_tooling-0.
|
67
|
+
prediction_market_agent_tooling-0.20.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
68
|
+
prediction_market_agent_tooling-0.20.0.dist-info/METADATA,sha256=AY6jt-QfmhXK25mX52MacYm0y667hC1hdpgO2ymMX-k,5510
|
69
|
+
prediction_market_agent_tooling-0.20.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
70
|
+
prediction_market_agent_tooling-0.20.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
71
|
+
prediction_market_agent_tooling-0.20.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|