prediction-market-agent-tooling 0.39.5__py3-none-any.whl → 0.41.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/config.py +19 -5
- prediction_market_agent_tooling/deploy/agent.py +8 -2
- prediction_market_agent_tooling/markets/markets.py +5 -0
- prediction_market_agent_tooling/markets/metaculus/api.py +97 -0
- prediction_market_agent_tooling/markets/metaculus/data_models.py +90 -0
- prediction_market_agent_tooling/markets/metaculus/metaculus.py +102 -0
- prediction_market_agent_tooling/markets/omen/omen.py +42 -1
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +1 -4
- prediction_market_agent_tooling/monitor/markets/metaculus.py +43 -0
- prediction_market_agent_tooling/monitor/monitor_app.py +4 -0
- {prediction_market_agent_tooling-0.39.5.dist-info → prediction_market_agent_tooling-0.41.0.dist-info}/METADATA +1 -1
- {prediction_market_agent_tooling-0.39.5.dist-info → prediction_market_agent_tooling-0.41.0.dist-info}/RECORD +15 -11
- {prediction_market_agent_tooling-0.39.5.dist-info → prediction_market_agent_tooling-0.41.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.39.5.dist-info → prediction_market_agent_tooling-0.41.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.39.5.dist-info → prediction_market_agent_tooling-0.41.0.dist-info}/entry_points.txt +0 -0
@@ -24,6 +24,8 @@ class APIKeys(BaseSettings):
|
|
24
24
|
)
|
25
25
|
|
26
26
|
MANIFOLD_API_KEY: t.Optional[SecretStr] = None
|
27
|
+
METACULUS_API_KEY: t.Optional[SecretStr] = None
|
28
|
+
METACULUS_USER_ID: t.Optional[int] = None
|
27
29
|
BET_FROM_PRIVATE_KEY: t.Optional[PrivateKey] = None
|
28
30
|
SAFE_ADDRESS: t.Optional[ChecksumAddress] = None
|
29
31
|
OPENAI_API_KEY: t.Optional[SecretStr] = None
|
@@ -51,6 +53,18 @@ class APIKeys(BaseSettings):
|
|
51
53
|
self.MANIFOLD_API_KEY, "MANIFOLD_API_KEY missing in the environment."
|
52
54
|
)
|
53
55
|
|
56
|
+
@property
|
57
|
+
def metaculus_api_key(self) -> SecretStr:
|
58
|
+
return check_not_none(
|
59
|
+
self.METACULUS_API_KEY, "METACULUS_API_KEY missing in the environment."
|
60
|
+
)
|
61
|
+
|
62
|
+
@property
|
63
|
+
def metaculus_user_id(self) -> int:
|
64
|
+
return check_not_none(
|
65
|
+
self.METACULUS_USER_ID, "METACULUS_USER_ID missing in the environment."
|
66
|
+
)
|
67
|
+
|
54
68
|
@property
|
55
69
|
def bet_from_private_key(self) -> PrivateKey:
|
56
70
|
return check_not_none(
|
@@ -58,14 +72,14 @@ class APIKeys(BaseSettings):
|
|
58
72
|
"BET_FROM_PRIVATE_KEY missing in the environment.",
|
59
73
|
)
|
60
74
|
|
75
|
+
@property
|
76
|
+
def public_key(self) -> ChecksumAddress:
|
77
|
+
return private_key_to_public_key(self.bet_from_private_key)
|
78
|
+
|
61
79
|
@property
|
62
80
|
def bet_from_address(self) -> ChecksumAddress:
|
63
81
|
"""If the SAFE is available, we always route transactions via SAFE. Otherwise we use the EOA."""
|
64
|
-
return
|
65
|
-
self.SAFE_ADDRESS
|
66
|
-
if self.SAFE_ADDRESS
|
67
|
-
else private_key_to_public_key(self.bet_from_private_key)
|
68
|
-
)
|
82
|
+
return self.SAFE_ADDRESS if self.SAFE_ADDRESS else self.public_key
|
69
83
|
|
70
84
|
@property
|
71
85
|
def openai_api_key(self) -> SecretStr:
|
@@ -22,7 +22,7 @@ from prediction_market_agent_tooling.deploy.gcp.utils import (
|
|
22
22
|
gcp_function_is_active,
|
23
23
|
gcp_resolve_api_keys_secrets,
|
24
24
|
)
|
25
|
-
from prediction_market_agent_tooling.gtypes import Probability
|
25
|
+
from prediction_market_agent_tooling.gtypes import Probability, xdai_type
|
26
26
|
from prediction_market_agent_tooling.loggers import logger
|
27
27
|
from prediction_market_agent_tooling.markets.agent_market import (
|
28
28
|
AgentMarket,
|
@@ -36,6 +36,7 @@ from prediction_market_agent_tooling.markets.markets import (
|
|
36
36
|
)
|
37
37
|
from prediction_market_agent_tooling.markets.omen.omen import (
|
38
38
|
redeem_from_all_user_positions,
|
39
|
+
withdraw_wxdai_to_xdai_to_keep_balance,
|
39
40
|
)
|
40
41
|
from prediction_market_agent_tooling.monitor.langfuse.langfuse_wrapper import (
|
41
42
|
LangfuseWrapper,
|
@@ -260,9 +261,14 @@ class DeployableTraderAgent(DeployableAgent):
|
|
260
261
|
"""
|
261
262
|
Executes actions that occur before bets are placed.
|
262
263
|
"""
|
264
|
+
api_keys = APIKeys()
|
263
265
|
if market_type == MarketType.OMEN:
|
264
266
|
# Omen is specific, because the user (agent) needs to manually withdraw winnings from the market.
|
265
|
-
redeem_from_all_user_positions(
|
267
|
+
redeem_from_all_user_positions(api_keys)
|
268
|
+
# Exchange wxdai back to xdai if the balance is getting low, so we can keep paying for fees.
|
269
|
+
withdraw_wxdai_to_xdai_to_keep_balance(
|
270
|
+
api_keys, min_required_balance=xdai_type(1), withdraw_multiplier=2
|
271
|
+
)
|
266
272
|
|
267
273
|
def process_bets(self, market_type: MarketType) -> None:
|
268
274
|
"""
|
@@ -16,6 +16,9 @@ from prediction_market_agent_tooling.markets.manifold.api import (
|
|
16
16
|
from prediction_market_agent_tooling.markets.manifold.manifold import (
|
17
17
|
ManifoldAgentMarket,
|
18
18
|
)
|
19
|
+
from prediction_market_agent_tooling.markets.metaculus.metaculus import (
|
20
|
+
MetaculusAgentMarket,
|
21
|
+
)
|
19
22
|
from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
|
20
23
|
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
21
24
|
OmenSubgraphHandler,
|
@@ -30,6 +33,7 @@ class MarketType(str, Enum):
|
|
30
33
|
MANIFOLD = "manifold"
|
31
34
|
OMEN = "omen"
|
32
35
|
POLYMARKET = "polymarket"
|
36
|
+
METACULUS = "metaculus"
|
33
37
|
|
34
38
|
@property
|
35
39
|
def market_class(self) -> type[AgentMarket]:
|
@@ -42,6 +46,7 @@ MARKET_TYPE_TO_AGENT_MARKET: dict[MarketType, type[AgentMarket]] = {
|
|
42
46
|
MarketType.MANIFOLD: ManifoldAgentMarket,
|
43
47
|
MarketType.OMEN: OmenAgentMarket,
|
44
48
|
MarketType.POLYMARKET: PolymarketAgentMarket,
|
49
|
+
MarketType.METACULUS: MetaculusAgentMarket,
|
45
50
|
}
|
46
51
|
|
47
52
|
|
@@ -0,0 +1,97 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from typing import Union
|
3
|
+
|
4
|
+
import requests
|
5
|
+
|
6
|
+
from prediction_market_agent_tooling.config import APIKeys
|
7
|
+
from prediction_market_agent_tooling.gtypes import Probability
|
8
|
+
from prediction_market_agent_tooling.markets.metaculus.data_models import (
|
9
|
+
MetaculusQuestion,
|
10
|
+
)
|
11
|
+
from prediction_market_agent_tooling.tools.utils import (
|
12
|
+
response_list_to_model,
|
13
|
+
response_to_model,
|
14
|
+
)
|
15
|
+
|
16
|
+
METACULUS_API_BASE_URL = "https://www.metaculus.com/api2"
|
17
|
+
|
18
|
+
|
19
|
+
def get_auth_headers() -> dict[str, str]:
|
20
|
+
return {"Authorization": f"Token {APIKeys().metaculus_api_key.get_secret_value()}"}
|
21
|
+
|
22
|
+
|
23
|
+
def post_question_comment(question_id: str, comment_text: str) -> None:
|
24
|
+
"""
|
25
|
+
Post a comment on the question page as the bot user.
|
26
|
+
"""
|
27
|
+
|
28
|
+
response = requests.post(
|
29
|
+
f"{METACULUS_API_BASE_URL}/comments/",
|
30
|
+
json={
|
31
|
+
"comment_text": comment_text,
|
32
|
+
"submit_type": "N",
|
33
|
+
"include_latest_prediction": True,
|
34
|
+
"question": question_id,
|
35
|
+
},
|
36
|
+
headers=get_auth_headers(),
|
37
|
+
)
|
38
|
+
response.raise_for_status()
|
39
|
+
|
40
|
+
|
41
|
+
def make_prediction(question_id: str, p_yes: Probability) -> None:
|
42
|
+
"""
|
43
|
+
Make a prediction for a question.
|
44
|
+
"""
|
45
|
+
url = f"{METACULUS_API_BASE_URL}/questions/{question_id}/predict/"
|
46
|
+
response = requests.post(
|
47
|
+
url,
|
48
|
+
json={"prediction": p_yes},
|
49
|
+
headers=get_auth_headers(),
|
50
|
+
)
|
51
|
+
response.raise_for_status()
|
52
|
+
|
53
|
+
|
54
|
+
def get_question(question_id: str) -> MetaculusQuestion:
|
55
|
+
"""
|
56
|
+
Get all details about a specific question.
|
57
|
+
"""
|
58
|
+
url = f"{METACULUS_API_BASE_URL}/questions/{question_id}/"
|
59
|
+
return response_to_model(
|
60
|
+
response=requests.get(url, headers=get_auth_headers()),
|
61
|
+
model=MetaculusQuestion,
|
62
|
+
)
|
63
|
+
|
64
|
+
|
65
|
+
def get_questions(
|
66
|
+
limit: int,
|
67
|
+
order_by: str | None = None,
|
68
|
+
offset: int = 0,
|
69
|
+
tournament_id: int | None = None,
|
70
|
+
created_after: datetime | None = None,
|
71
|
+
status: str | None = None,
|
72
|
+
) -> list[MetaculusQuestion]:
|
73
|
+
"""
|
74
|
+
List detailed metaculus questions (i.e. markets)
|
75
|
+
"""
|
76
|
+
url_params: dict[str, Union[int, str]] = {
|
77
|
+
"limit": limit,
|
78
|
+
"offset": offset,
|
79
|
+
"has_group": "false",
|
80
|
+
"forecast_type": "binary",
|
81
|
+
"type": "forecast",
|
82
|
+
"include_description": "true",
|
83
|
+
}
|
84
|
+
if order_by:
|
85
|
+
url_params["order_by"] = order_by
|
86
|
+
if tournament_id:
|
87
|
+
url_params["project"] = tournament_id
|
88
|
+
if created_after:
|
89
|
+
url_params["created_time__gt"] = created_after.isoformat()
|
90
|
+
if status:
|
91
|
+
url_params["status"] = status
|
92
|
+
|
93
|
+
url = f"{METACULUS_API_BASE_URL}/questions/"
|
94
|
+
return response_list_to_model(
|
95
|
+
response=requests.get(url, headers=get_auth_headers(), params=url_params),
|
96
|
+
model=MetaculusQuestion,
|
97
|
+
)
|
@@ -0,0 +1,90 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
from enum import Enum
|
3
|
+
from typing import Any
|
4
|
+
|
5
|
+
from pydantic import BaseModel
|
6
|
+
|
7
|
+
|
8
|
+
class QuestionType(str, Enum):
|
9
|
+
forecast = "forecast"
|
10
|
+
notebook = "notebook"
|
11
|
+
discussion = "discussion"
|
12
|
+
claim = "claim"
|
13
|
+
group = "group"
|
14
|
+
conditional_group = "conditional_group"
|
15
|
+
multiple_choice = "multiple_choice"
|
16
|
+
|
17
|
+
|
18
|
+
class CommunityPrediction(BaseModel):
|
19
|
+
y: list[float]
|
20
|
+
q1: float | None = None
|
21
|
+
q2: float | None = None
|
22
|
+
q3: float | None = None
|
23
|
+
|
24
|
+
@property
|
25
|
+
def p_yes(self) -> float:
|
26
|
+
"""
|
27
|
+
q2 corresponds to the median, or 'second quartile' of the distribution.
|
28
|
+
|
29
|
+
If no value is provided (i.e. the question is new and has not been
|
30
|
+
answered yet), we default to 0.5.
|
31
|
+
"""
|
32
|
+
return self.q2 if self.q2 is not None else 0.5
|
33
|
+
|
34
|
+
|
35
|
+
class Prediction(BaseModel):
|
36
|
+
t: datetime
|
37
|
+
x: float
|
38
|
+
|
39
|
+
|
40
|
+
class UserPredictions(BaseModel):
|
41
|
+
id: int
|
42
|
+
predictions: list[Prediction]
|
43
|
+
points_won: float | None = None
|
44
|
+
user: int
|
45
|
+
username: str
|
46
|
+
question: int
|
47
|
+
|
48
|
+
|
49
|
+
class CommunityPredictionStats(BaseModel):
|
50
|
+
full: CommunityPrediction
|
51
|
+
unweighted: CommunityPrediction
|
52
|
+
|
53
|
+
|
54
|
+
class MetaculusQuestion(BaseModel):
|
55
|
+
"""
|
56
|
+
https://www.metaculus.com/api2/schema/redoc/#tag/questions/operation/questions_retrieve
|
57
|
+
"""
|
58
|
+
|
59
|
+
active_state: Any
|
60
|
+
url: str
|
61
|
+
page_url: str
|
62
|
+
id: int
|
63
|
+
author: int
|
64
|
+
author_name: str
|
65
|
+
author_id: int
|
66
|
+
title: str
|
67
|
+
title_short: str
|
68
|
+
group_label: str | None = None
|
69
|
+
resolution: int | None
|
70
|
+
resolved_option: int | None
|
71
|
+
created_time: datetime
|
72
|
+
publish_time: datetime | None = None
|
73
|
+
close_time: datetime | None = None
|
74
|
+
effected_close_time: datetime | None
|
75
|
+
resolve_time: datetime | None = None
|
76
|
+
possibilities: dict[Any, Any] | None = None
|
77
|
+
scoring: dict[Any, Any] = {}
|
78
|
+
type: QuestionType | None = None
|
79
|
+
user_perms: Any
|
80
|
+
weekly_movement: float | None
|
81
|
+
weekly_movement_direction: int | None = None
|
82
|
+
cp_reveal_time: datetime | None = None
|
83
|
+
edited_time: datetime
|
84
|
+
last_activity_time: datetime
|
85
|
+
activity: float
|
86
|
+
comment_count: int
|
87
|
+
votes: int
|
88
|
+
community_prediction: CommunityPredictionStats
|
89
|
+
my_predictions: UserPredictions | None = None
|
90
|
+
# TODO add the rest of the fields https://github.com/gnosis/prediction-market-agent-tooling/issues/301
|
@@ -0,0 +1,102 @@
|
|
1
|
+
import typing as t
|
2
|
+
from datetime import datetime
|
3
|
+
|
4
|
+
from prediction_market_agent_tooling.gtypes import Probability
|
5
|
+
from prediction_market_agent_tooling.markets.agent_market import (
|
6
|
+
AgentMarket,
|
7
|
+
FilterBy,
|
8
|
+
SortBy,
|
9
|
+
)
|
10
|
+
from prediction_market_agent_tooling.markets.metaculus.api import (
|
11
|
+
METACULUS_API_BASE_URL,
|
12
|
+
get_questions,
|
13
|
+
make_prediction,
|
14
|
+
post_question_comment,
|
15
|
+
)
|
16
|
+
from prediction_market_agent_tooling.markets.metaculus.data_models import (
|
17
|
+
MetaculusQuestion,
|
18
|
+
)
|
19
|
+
|
20
|
+
|
21
|
+
class MetaculusAgentMarket(AgentMarket):
|
22
|
+
"""
|
23
|
+
Metaculus' market class that can be used by agents to make predictions.
|
24
|
+
"""
|
25
|
+
|
26
|
+
have_predicted: bool
|
27
|
+
base_url: t.ClassVar[str] = METACULUS_API_BASE_URL
|
28
|
+
|
29
|
+
@staticmethod
|
30
|
+
def from_data_model(model: MetaculusQuestion) -> "MetaculusAgentMarket":
|
31
|
+
return MetaculusAgentMarket(
|
32
|
+
id=str(model.id),
|
33
|
+
question=model.title,
|
34
|
+
outcomes=[],
|
35
|
+
resolution=None,
|
36
|
+
current_p_yes=Probability(model.community_prediction.full.p_yes),
|
37
|
+
created_time=model.created_time,
|
38
|
+
close_time=model.close_time,
|
39
|
+
url=model.url,
|
40
|
+
volume=None,
|
41
|
+
have_predicted=model.my_predictions is not None
|
42
|
+
and len(model.my_predictions.predictions) > 0,
|
43
|
+
)
|
44
|
+
|
45
|
+
@staticmethod
|
46
|
+
def get_binary_markets(
|
47
|
+
limit: int,
|
48
|
+
sort_by: SortBy = SortBy.NONE,
|
49
|
+
filter_by: FilterBy = FilterBy.OPEN,
|
50
|
+
created_after: t.Optional[datetime] = None,
|
51
|
+
excluded_questions: set[str] | None = None,
|
52
|
+
tournament_id: int | None = None,
|
53
|
+
) -> t.Sequence["MetaculusAgentMarket"]:
|
54
|
+
order_by: str | None
|
55
|
+
if sort_by == SortBy.NONE:
|
56
|
+
order_by = None
|
57
|
+
elif sort_by == SortBy.CLOSING_SOONEST:
|
58
|
+
order_by = "-close_time"
|
59
|
+
elif sort_by == SortBy.NEWEST:
|
60
|
+
order_by = "-created_time"
|
61
|
+
else:
|
62
|
+
raise ValueError(f"Unknown sort_by: {sort_by}")
|
63
|
+
|
64
|
+
status: str | None
|
65
|
+
if filter_by == FilterBy.OPEN:
|
66
|
+
status = "open"
|
67
|
+
elif filter_by == FilterBy.RESOLVED:
|
68
|
+
status = "resolved"
|
69
|
+
elif filter_by == FilterBy.NONE:
|
70
|
+
status = None
|
71
|
+
else:
|
72
|
+
raise ValueError(f"Unknown filter_by: {filter_by}")
|
73
|
+
|
74
|
+
if excluded_questions:
|
75
|
+
raise NotImplementedError(
|
76
|
+
"Excluded questions are not suppoerted for Metaculus markets yet."
|
77
|
+
)
|
78
|
+
|
79
|
+
offset = 0
|
80
|
+
question_page_size = 500
|
81
|
+
all_questions = []
|
82
|
+
while True:
|
83
|
+
questions = get_questions(
|
84
|
+
limit=question_page_size,
|
85
|
+
offset=offset,
|
86
|
+
order_by=order_by,
|
87
|
+
created_after=created_after,
|
88
|
+
status=status,
|
89
|
+
tournament_id=tournament_id,
|
90
|
+
)
|
91
|
+
if not questions:
|
92
|
+
break
|
93
|
+
all_questions.extend(questions)
|
94
|
+
offset += question_page_size
|
95
|
+
|
96
|
+
if len(all_questions) >= limit:
|
97
|
+
break
|
98
|
+
return [MetaculusAgentMarket.from_data_model(q) for q in all_questions]
|
99
|
+
|
100
|
+
def submit_prediction(self, p_yes: Probability, reasoning: str) -> None:
|
101
|
+
make_prediction(self.id, p_yes)
|
102
|
+
post_question_comment(self.id, reasoning)
|
@@ -489,7 +489,11 @@ class OmenAgentMarket(AgentMarket):
|
|
489
489
|
|
490
490
|
@classmethod
|
491
491
|
def get_user_url(cls, keys: APIKeys) -> str:
|
492
|
-
return
|
492
|
+
return get_omen_user_url(keys.bet_from_address)
|
493
|
+
|
494
|
+
|
495
|
+
def get_omen_user_url(address: ChecksumAddress) -> str:
|
496
|
+
return f"https://gnosisscan.io/address/{address}"
|
493
497
|
|
494
498
|
|
495
499
|
def pick_binary_market(
|
@@ -1000,3 +1004,40 @@ def get_binary_market_p_yes_history(market: OmenAgentMarket) -> list[Probability
|
|
1000
1004
|
)
|
1001
1005
|
|
1002
1006
|
return history
|
1007
|
+
|
1008
|
+
|
1009
|
+
def withdraw_wxdai_to_xdai_to_keep_balance(
|
1010
|
+
api_keys: APIKeys,
|
1011
|
+
min_required_balance: xDai,
|
1012
|
+
withdraw_multiplier: float = 1.0,
|
1013
|
+
web3: Web3 | None = None,
|
1014
|
+
) -> None:
|
1015
|
+
"""
|
1016
|
+
Keeps xDai balance above the minimum required balance by withdrawing wxDai to xDai.
|
1017
|
+
Optionally, the amount to withdraw can be multiplied by the `withdraw_multiplier`, which can be useful to keep a buffer.
|
1018
|
+
"""
|
1019
|
+
# xDai needs to be in our wallet where we pay transaction fees, so do not check for Safe's balance.
|
1020
|
+
current_balances = get_balances(api_keys.public_key, web3)
|
1021
|
+
|
1022
|
+
if current_balances.xdai >= min_required_balance:
|
1023
|
+
logger.info(
|
1024
|
+
f"Current xDai balance {current_balances.xdai} is more or equal than the required minimum balance {min_required_balance}."
|
1025
|
+
)
|
1026
|
+
return
|
1027
|
+
|
1028
|
+
need_to_withdraw = xDai(
|
1029
|
+
(min_required_balance - current_balances.xdai) * withdraw_multiplier
|
1030
|
+
)
|
1031
|
+
|
1032
|
+
if current_balances.wxdai < need_to_withdraw:
|
1033
|
+
raise ValueError(
|
1034
|
+
f"Current wxDai balance {current_balances.wxdai} is less than the required minimum wxDai to withdraw {need_to_withdraw}."
|
1035
|
+
)
|
1036
|
+
|
1037
|
+
collateral_token_contract = OmenCollateralTokenContract()
|
1038
|
+
collateral_token_contract.withdraw(
|
1039
|
+
api_keys=api_keys, amount_wei=xdai_to_wei(need_to_withdraw), web3=web3
|
1040
|
+
)
|
1041
|
+
logger.info(
|
1042
|
+
f"Withdrew {need_to_withdraw} wxDai to keep the balance above the minimum required balance {min_required_balance}."
|
1043
|
+
)
|
@@ -45,10 +45,7 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
45
45
|
|
46
46
|
REALITYETH_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/E7ymrCnNcQdAAgLbdFWzGE5mvr5Mb5T9VfT43FqA7bNh"
|
47
47
|
|
48
|
-
|
49
|
-
OMEN_IMAGE_MAPPING_GRAPH_URL = (
|
50
|
-
"https://api.studio.thegraph.com/query/63564/omen-thumbnailmapping/v0.0.3"
|
51
|
-
)
|
48
|
+
OMEN_IMAGE_MAPPING_GRAPH_URL = "https://gateway-arbitrum.network.thegraph.com/api/{graph_api_key}/subgraphs/id/EWN14ciGK53PpUiKSm7kMWQ6G4iz3tDrRLyZ1iXMQEdu"
|
52
49
|
|
53
50
|
INVALID_ANSWER = "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
|
54
51
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import typing as t
|
2
|
+
|
3
|
+
from google.cloud.functions_v2.types.functions import Function
|
4
|
+
|
5
|
+
from prediction_market_agent_tooling.config import APIKeys
|
6
|
+
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
|
+
from prediction_market_agent_tooling.gtypes import DatetimeWithTimezone
|
8
|
+
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
9
|
+
from prediction_market_agent_tooling.markets.markets import MarketType
|
10
|
+
from prediction_market_agent_tooling.monitor.monitor import DeployedAgent
|
11
|
+
|
12
|
+
|
13
|
+
class DeployedMetaculusAgent(DeployedAgent):
|
14
|
+
user: int
|
15
|
+
|
16
|
+
@property
|
17
|
+
def public_id(self) -> str:
|
18
|
+
return str(self.user)
|
19
|
+
|
20
|
+
def get_resolved_bets(self) -> list[ResolvedBet]:
|
21
|
+
raise NotImplementedError("TODO: Implement to allow betting on Metaculus.")
|
22
|
+
|
23
|
+
@staticmethod
|
24
|
+
def from_api_keys(
|
25
|
+
name: str,
|
26
|
+
start_time: DatetimeWithTimezone,
|
27
|
+
api_keys: APIKeys,
|
28
|
+
) -> "DeployedMetaculusAgent":
|
29
|
+
return DeployedMetaculusAgent(
|
30
|
+
name=name,
|
31
|
+
start_time=start_time,
|
32
|
+
user=api_keys.metaculus_user_id,
|
33
|
+
)
|
34
|
+
|
35
|
+
@classmethod
|
36
|
+
def from_all_gcp_functions(
|
37
|
+
cls: t.Type["DeployedMetaculusAgent"],
|
38
|
+
filter_: t.Callable[[Function], bool] = lambda function: function.labels[
|
39
|
+
MARKET_TYPE_KEY
|
40
|
+
]
|
41
|
+
== MarketType.METACULUS.value,
|
42
|
+
) -> t.Sequence["DeployedMetaculusAgent"]:
|
43
|
+
return super().from_all_gcp_functions(filter_=filter_)
|
@@ -13,6 +13,9 @@ from prediction_market_agent_tooling.markets.markets import MarketType
|
|
13
13
|
from prediction_market_agent_tooling.monitor.markets.manifold import (
|
14
14
|
DeployedManifoldAgent,
|
15
15
|
)
|
16
|
+
from prediction_market_agent_tooling.monitor.markets.metaculus import (
|
17
|
+
DeployedMetaculusAgent,
|
18
|
+
)
|
16
19
|
from prediction_market_agent_tooling.monitor.markets.omen import DeployedOmenAgent
|
17
20
|
from prediction_market_agent_tooling.monitor.markets.polymarket import (
|
18
21
|
DeployedPolymarketAgent,
|
@@ -36,6 +39,7 @@ MARKET_TYPE_TO_DEPLOYED_AGENT: dict[MarketType, type[DeployedAgent]] = {
|
|
36
39
|
MarketType.MANIFOLD: DeployedManifoldAgent,
|
37
40
|
MarketType.OMEN: DeployedOmenAgent,
|
38
41
|
MarketType.POLYMARKET: DeployedPolymarketAgent,
|
42
|
+
MarketType.METACULUS: DeployedMetaculusAgent,
|
39
43
|
}
|
40
44
|
|
41
45
|
|
@@ -12,8 +12,8 @@ prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-
|
|
12
12
|
prediction_market_agent_tooling/benchmark/agents.py,sha256=HPIFJvackW110ch3UkktbxhU48gMRVo4gQse84Klhdc,4000
|
13
13
|
prediction_market_agent_tooling/benchmark/benchmark.py,sha256=xiHKzZx5GHSsDerFHMZ9j_LXAXnSaITSvv67iPe3MEU,21095
|
14
14
|
prediction_market_agent_tooling/benchmark/utils.py,sha256=iS1BzyXcCMfMm1Rx--1QCH0pHvBTblTndcDQFbTUJ2s,2897
|
15
|
-
prediction_market_agent_tooling/config.py,sha256=
|
16
|
-
prediction_market_agent_tooling/deploy/agent.py,sha256=
|
15
|
+
prediction_market_agent_tooling/config.py,sha256=beNwFgOpe30lIFIvwyXKzH86jNzkvqKARosKkrl_mmg,5026
|
16
|
+
prediction_market_agent_tooling/deploy/agent.py,sha256=TXuQ0L2-dG0tIrJ7srxD3Hbabe_2gILfdBQI-tkl9Og,10522
|
17
17
|
prediction_market_agent_tooling/deploy/agent_example.py,sha256=tqXVA2HSFK3pdZ49tMmta8aKdJFT8JN8WeJ1akjrpBk,909
|
18
18
|
prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
|
19
19
|
prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
|
@@ -29,13 +29,16 @@ prediction_market_agent_tooling/markets/manifold/api.py,sha256=m6qOzDiyQfxj62Eo_
|
|
29
29
|
prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=xoCqxk9cO6MZ_px_SEGYZ8hHyhGh-X6QDC8dDhyF3rk,5302
|
30
30
|
prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=EwRL06E2Y_ZAzr8efwS5yD6p6rnykrcBhqmNDUGZ8Aw,4075
|
31
31
|
prediction_market_agent_tooling/markets/manifold/utils.py,sha256=cPPFWXm3vCYH1jy7_ctJZuQH9ZDaPL4_AgAYzGWkoow,513
|
32
|
-
prediction_market_agent_tooling/markets/markets.py,sha256=
|
32
|
+
prediction_market_agent_tooling/markets/markets.py,sha256=Hz3E7LJ5HIjCHQtdU5_Bymav2dYT0dDxKOL0i8mV0mg,3142
|
33
|
+
prediction_market_agent_tooling/markets/metaculus/api.py,sha256=uE11iNTT5RahJq7S_ZnAYDRsFCVT7dbQejbDH-JoeI4,2759
|
34
|
+
prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=OOCwj6PXyPIDq3jNqp76CqBADD7ax9xJp-Ude39jzOg,2326
|
35
|
+
prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=KMWksTNFCKxqjeMiuRh5yNarPSv7sH0aDkgeC3fm3Dg,3293
|
33
36
|
prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
34
37
|
prediction_market_agent_tooling/markets/omen/data_models.py,sha256=EXtjmcujx68Xu50BVkYXvLuf_Asx5o65RvFS3ZS6HGs,14405
|
35
|
-
prediction_market_agent_tooling/markets/omen/omen.py,sha256=
|
38
|
+
prediction_market_agent_tooling/markets/omen/omen.py,sha256=0ua3bv8gc2aRHMg1UnuvqS-i7YE-QVzMJs07XgiR1n8,38445
|
36
39
|
prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=JGXCO9MIVr-DGyoH2sxReAw7ZDTC_ev0UxDpq1QBv5Q,21854
|
37
40
|
prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=g77QsQ5WnSI2rzBlX87L_EhWMwobkyXyfRhHQmpAdzo,9012
|
38
|
-
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=
|
41
|
+
prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=kDbeZ8ImLtBSFz0GoGdCqeC1Xd3_eGMAxvmLFT8kp8Y,25222
|
39
42
|
prediction_market_agent_tooling/markets/polymarket/api.py,sha256=HXmA1akA0qDj0m3e-GEvWG8x75pm6BX4H7YJPQcST7I,4767
|
40
43
|
prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=9CJzakyEcsn6DQBK2nOXjOMzTZBLAmK_KqevXvW17DI,4292
|
41
44
|
prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=f8SRQy0Rn-gIHSEMrJJAI8H3J7l8lzOLj3aCMe0vJv8,11324
|
@@ -43,10 +46,11 @@ prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=zqGfiUOH
|
|
43
46
|
prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=m4JG6WULh5epCJt4XBMHg0ae5NoVhqlOvAl0A7DR9iM,2023
|
44
47
|
prediction_market_agent_tooling/monitor/langfuse/langfuse_wrapper.py,sha256=b6T69YB1x8kSUvW9uRFuSWPLOrXzapZG7m5O5SU0QTQ,895
|
45
48
|
prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=GdYpgRX1GahDi-75Mr53jgtEg6nWcs_rHDUkg4o_7dQ,3352
|
49
|
+
prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=S8zeDVN2aA6yvQykQNPb8GUGohczfJuCYt9Ds9ESCzs,1473
|
46
50
|
prediction_market_agent_tooling/monitor/markets/omen.py,sha256=jOLPnIbDU9syjnYtHfOb2xa6-Ize3vbplgh-8WWkuT4,3323
|
47
51
|
prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=I9z9aO1wncyGI3a09ihrw17JkeBKjAuMmC0I9pl_9o4,1781
|
48
52
|
prediction_market_agent_tooling/monitor/monitor.py,sha256=uJdaEpGWp4VcejoQLF0uOxhV75AhrXNyWPVG38gBeOo,14505
|
49
|
-
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=
|
53
|
+
prediction_market_agent_tooling/monitor/monitor_app.py,sha256=THyZ67baByakoOm3hIqWOFOBCzg1ZMb_ILgXQ6y0NwE,4763
|
50
54
|
prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
|
51
55
|
prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
52
56
|
prediction_market_agent_tooling/tools/balances.py,sha256=nR8_dSfbm3yTOOmMAwhGlurftEiNo1w1WIVzbskjdmM,837
|
@@ -69,8 +73,8 @@ prediction_market_agent_tooling/tools/singleton.py,sha256=CiIELUiI-OeS7U7eeHEt0r
|
|
69
73
|
prediction_market_agent_tooling/tools/streamlit_user_login.py,sha256=NXEqfjT9Lc9QtliwSGRASIz1opjQ7Btme43H4qJbzgE,3010
|
70
74
|
prediction_market_agent_tooling/tools/utils.py,sha256=-G22UEbCRm59bm1RWFdeF55hRsaxgwZVAHvK32-Ye1g,6190
|
71
75
|
prediction_market_agent_tooling/tools/web3_utils.py,sha256=nKRHmdLnWSKd3wpo-cysXGvhhrJ2Yf69sN2FFQfSt6s,10578
|
72
|
-
prediction_market_agent_tooling-0.
|
73
|
-
prediction_market_agent_tooling-0.
|
74
|
-
prediction_market_agent_tooling-0.
|
75
|
-
prediction_market_agent_tooling-0.
|
76
|
-
prediction_market_agent_tooling-0.
|
76
|
+
prediction_market_agent_tooling-0.41.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
|
77
|
+
prediction_market_agent_tooling-0.41.0.dist-info/METADATA,sha256=wYeKmF4ZK5-armVe80q2Lfb0byXJewmwC43HiuNMC6M,7634
|
78
|
+
prediction_market_agent_tooling-0.41.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
79
|
+
prediction_market_agent_tooling-0.41.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
|
80
|
+
prediction_market_agent_tooling-0.41.0.dist-info/RECORD,,
|
File without changes
|
File without changes
|