prediction-market-agent-tooling 0.16.0__py3-none-any.whl → 0.17.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/benchmark/agents.py +5 -2
- prediction_market_agent_tooling/benchmark/utils.py +2 -3
- prediction_market_agent_tooling/deploy/agent.py +40 -3
- prediction_market_agent_tooling/deploy/agent_example.py +14 -4
- {prediction_market_agent_tooling-0.16.0.dist-info → prediction_market_agent_tooling-0.17.0.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.16.0.dist-info → prediction_market_agent_tooling-0.17.0.dist-info}/RECORD +9 -9
- {prediction_market_agent_tooling-0.16.0.dist-info → prediction_market_agent_tooling-0.17.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.16.0.dist-info → prediction_market_agent_tooling-0.17.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.16.0.dist-info → prediction_market_agent_tooling-0.17.0.dist-info}/entry_points.txt +0 -0
@@ -6,6 +6,7 @@ from prediction_market_agent_tooling.benchmark.utils import (
|
|
6
6
|
OutcomePrediction,
|
7
7
|
Prediction,
|
8
8
|
)
|
9
|
+
from prediction_market_agent_tooling.gtypes import Probability
|
9
10
|
|
10
11
|
|
11
12
|
class AbstractBenchmarkedAgent:
|
@@ -86,7 +87,8 @@ class RandomAgent(AbstractBenchmarkedAgent):
|
|
86
87
|
p_yes, confidence = random.random(), random.random()
|
87
88
|
return Prediction(
|
88
89
|
outcome_prediction=OutcomePrediction(
|
89
|
-
|
90
|
+
decision=p_yes > 0.5,
|
91
|
+
p_yes=Probability(p_yes),
|
90
92
|
confidence=confidence,
|
91
93
|
info_utility=None,
|
92
94
|
),
|
@@ -109,7 +111,8 @@ class FixedAgent(AbstractBenchmarkedAgent):
|
|
109
111
|
p_yes, confidence = 1.0 if self.fixed_answer else 0.0, 1.0
|
110
112
|
return Prediction(
|
111
113
|
outcome_prediction=OutcomePrediction(
|
112
|
-
|
114
|
+
decision=self.fixed_answer,
|
115
|
+
p_yes=Probability(p_yes),
|
113
116
|
confidence=confidence,
|
114
117
|
info_utility=None,
|
115
118
|
),
|
@@ -3,12 +3,11 @@ import typing as t
|
|
3
3
|
|
4
4
|
from pydantic import BaseModel
|
5
5
|
|
6
|
+
from prediction_market_agent_tooling.deploy.agent import Answer
|
6
7
|
from prediction_market_agent_tooling.markets.data_models import Resolution
|
7
8
|
|
8
9
|
|
9
|
-
class OutcomePrediction(
|
10
|
-
p_yes: float
|
11
|
-
confidence: float
|
10
|
+
class OutcomePrediction(Answer):
|
12
11
|
info_utility: t.Optional[float]
|
13
12
|
|
14
13
|
@property
|
@@ -6,6 +6,8 @@ import typing as t
|
|
6
6
|
from datetime import datetime
|
7
7
|
|
8
8
|
from loguru import logger
|
9
|
+
from pydantic import BaseModel, BeforeValidator
|
10
|
+
from typing_extensions import Annotated
|
9
11
|
|
10
12
|
from prediction_market_agent_tooling.config import APIKeys, PrivateCredentials
|
11
13
|
from prediction_market_agent_tooling.deploy.constants import (
|
@@ -21,6 +23,7 @@ from prediction_market_agent_tooling.deploy.gcp.utils import (
|
|
21
23
|
gcp_function_is_active,
|
22
24
|
gcp_resolve_api_keys_secrets,
|
23
25
|
)
|
26
|
+
from prediction_market_agent_tooling.gtypes import Probability
|
24
27
|
from prediction_market_agent_tooling.markets.agent_market import (
|
25
28
|
AgentMarket,
|
26
29
|
FilterBy,
|
@@ -39,6 +42,40 @@ from prediction_market_agent_tooling.tools.utils import DatetimeWithTimezone, ut
|
|
39
42
|
MAX_AVAILABLE_MARKETS = 20
|
40
43
|
|
41
44
|
|
45
|
+
def to_boolean_outcome(value: str | bool) -> bool:
|
46
|
+
if isinstance(value, bool):
|
47
|
+
return value
|
48
|
+
|
49
|
+
elif isinstance(value, str):
|
50
|
+
value = value.lower().strip()
|
51
|
+
|
52
|
+
if value in {"true", "yes", "y", "1"}:
|
53
|
+
return True
|
54
|
+
|
55
|
+
elif value in {"false", "no", "n", "0"}:
|
56
|
+
return False
|
57
|
+
|
58
|
+
else:
|
59
|
+
raise ValueError(f"Expected a boolean string, but got {value}")
|
60
|
+
|
61
|
+
else:
|
62
|
+
raise ValueError(f"Expected a boolean or a string, but got {value}")
|
63
|
+
|
64
|
+
|
65
|
+
Decision = Annotated[bool, BeforeValidator(to_boolean_outcome)]
|
66
|
+
|
67
|
+
|
68
|
+
class Answer(BaseModel):
|
69
|
+
decision: Decision # Warning: p_yes > 0.5 doesn't necessarily mean decision is True! For example, if our p_yes is 55%, but market's p_yes is 80%, then it might be profitable to bet on False.
|
70
|
+
p_yes: Probability
|
71
|
+
confidence: float
|
72
|
+
reasoning: str | None = None
|
73
|
+
|
74
|
+
@property
|
75
|
+
def p_no(self) -> Probability:
|
76
|
+
return Probability(1 - self.p_yes)
|
77
|
+
|
78
|
+
|
42
79
|
class DeployableAgent:
|
43
80
|
def __init__(self) -> None:
|
44
81
|
self.load()
|
@@ -58,7 +95,7 @@ class DeployableAgent:
|
|
58
95
|
"""
|
59
96
|
return markets[:1]
|
60
97
|
|
61
|
-
def answer_binary_market(self, market: AgentMarket) ->
|
98
|
+
def answer_binary_market(self, market: AgentMarket) -> Answer | None:
|
62
99
|
"""
|
63
100
|
Answer the binary market. This method must be implemented by the subclass.
|
64
101
|
"""
|
@@ -157,7 +194,7 @@ def {entrypoint_function_name}(request) -> str:
|
|
157
194
|
if cron_schedule:
|
158
195
|
schedule_deployed_gcp_function(fname, cron_schedule=cron_schedule)
|
159
196
|
|
160
|
-
def calculate_bet_amount(self, answer:
|
197
|
+
def calculate_bet_amount(self, answer: Answer, market: AgentMarket) -> BetAmount:
|
161
198
|
"""
|
162
199
|
Calculate the bet amount. By default, it returns the minimum bet amount.
|
163
200
|
"""
|
@@ -205,7 +242,7 @@ def {entrypoint_function_name}(request) -> str:
|
|
205
242
|
)
|
206
243
|
market.place_bet(
|
207
244
|
amount=amount,
|
208
|
-
outcome=result,
|
245
|
+
outcome=result.decision,
|
209
246
|
)
|
210
247
|
|
211
248
|
def after(self, market_type: MarketType) -> None:
|
@@ -1,7 +1,11 @@
|
|
1
1
|
import random
|
2
2
|
import typing as t
|
3
3
|
|
4
|
-
from prediction_market_agent_tooling.deploy.agent import
|
4
|
+
from prediction_market_agent_tooling.deploy.agent import (
|
5
|
+
Answer,
|
6
|
+
DeployableAgent,
|
7
|
+
Probability,
|
8
|
+
)
|
5
9
|
from prediction_market_agent_tooling.markets.agent_market import AgentMarket
|
6
10
|
|
7
11
|
|
@@ -9,10 +13,16 @@ class DeployableCoinFlipAgent(DeployableAgent):
|
|
9
13
|
def pick_markets(self, markets: t.Sequence[AgentMarket]) -> t.Sequence[AgentMarket]:
|
10
14
|
return random.sample(markets, 1)
|
11
15
|
|
12
|
-
def answer_binary_market(self, market: AgentMarket) ->
|
13
|
-
|
16
|
+
def answer_binary_market(self, market: AgentMarket) -> Answer | None:
|
17
|
+
decision = random.choice([True, False])
|
18
|
+
return Answer(
|
19
|
+
decision=decision,
|
20
|
+
p_yes=Probability(float(decision)),
|
21
|
+
confidence=0.5,
|
22
|
+
reasoning="I flipped a coin to decide.",
|
23
|
+
)
|
14
24
|
|
15
25
|
|
16
26
|
class DeployableAlwaysRaiseAgent(DeployableAgent):
|
17
|
-
def answer_binary_market(self, market: AgentMarket) ->
|
27
|
+
def answer_binary_market(self, market: AgentMarket) -> Answer | None:
|
18
28
|
raise RuntimeError("I always raise!")
|
@@ -8,12 +8,12 @@ prediction_market_agent_tooling/abis/omen_oracle.abi.json,sha256=YPZ-FLvd4PA9pYd
|
|
8
8
|
prediction_market_agent_tooling/abis/omen_realitio.abi.json,sha256=7HmFkBF_rq83UTaH2kRRsEfc_WZuf4n-qvkB4nhvweo,15953
|
9
9
|
prediction_market_agent_tooling/abis/wxdai.abi.json,sha256=m3qC06Yug-pToI0lSFe1f8e6gKMIulnV3MA2K0X51hI,6055
|
10
10
|
prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
-
prediction_market_agent_tooling/benchmark/agents.py,sha256=
|
11
|
+
prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3UkktbxhU48gMRVo4gQse84Klhdc,4000
|
12
12
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
|
13
|
-
prediction_market_agent_tooling/benchmark/utils.py,sha256=
|
13
|
+
prediction_market_agent_tooling/benchmark/utils.py,sha256=iS1BzyXcCMfMm1Rx--1QCH0pHvBTblTndcDQFbTUJ2s,2897
|
14
14
|
prediction_market_agent_tooling/config.py,sha256=Cvl9RWlOEPRzdSE7-ChTyKSMNTgNoOYmtJ0lT5yDqpE,3570
|
15
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
16
|
-
prediction_market_agent_tooling/deploy/agent_example.py,sha256=
|
15
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=hpk2VvRBHU1d7_tcYaZg5V3bvhehl7ZgUjn3jc6iAMY,8916
|
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
|
19
19
|
prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=qYIHRxQLac3yxtZ8ChikiPG9O1aUQucHW0muTSm1nto,2627
|
@@ -63,8 +63,8 @@ prediction_market_agent_tooling/tools/safe.py,sha256=gNgcY6ugckx3DbupR8VBezDgh1d
|
|
63
63
|
prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0rnVhtQGzwoUdAgn_7u_GBM,729
|
64
64
|
prediction_market_agent_tooling/tools/utils.py,sha256=6MRfLr5xGPEQGobLz_eCsE_p-XaAeOCcmygwgNCIvqE,5044
|
65
65
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=tl_uN-SpKK4nXpqlSozefzMXpbAe9rFzaCB9IQ0QJxY,8335
|
66
|
-
prediction_market_agent_tooling-0.
|
67
|
-
prediction_market_agent_tooling-0.
|
68
|
-
prediction_market_agent_tooling-0.
|
69
|
-
prediction_market_agent_tooling-0.
|
70
|
-
prediction_market_agent_tooling-0.
|
66
|
+
prediction_market_agent_tooling-0.17.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
67
|
+
prediction_market_agent_tooling-0.17.0.dist-info/METADATA,sha256=Z-mAb4_umw_MR5dyNTEybglqltb3DTvvmOufBifARTk,5468
|
68
|
+
prediction_market_agent_tooling-0.17.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
69
|
+
prediction_market_agent_tooling-0.17.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
70
|
+
prediction_market_agent_tooling-0.17.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|