prediction-market-agent-tooling 0.64.12.dev659__py3-none-any.whl → 0.65.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.
Files changed (53) hide show
  1. prediction_market_agent_tooling/benchmark/agents.py +19 -16
  2. prediction_market_agent_tooling/benchmark/benchmark.py +94 -84
  3. prediction_market_agent_tooling/benchmark/utils.py +8 -9
  4. prediction_market_agent_tooling/chains.py +4 -0
  5. prediction_market_agent_tooling/config.py +4 -3
  6. prediction_market_agent_tooling/deploy/agent.py +85 -125
  7. prediction_market_agent_tooling/deploy/agent_example.py +20 -10
  8. prediction_market_agent_tooling/deploy/betting_strategy.py +222 -96
  9. prediction_market_agent_tooling/deploy/constants.py +4 -0
  10. prediction_market_agent_tooling/jobs/jobs_models.py +15 -4
  11. prediction_market_agent_tooling/jobs/omen/omen_jobs.py +3 -3
  12. prediction_market_agent_tooling/markets/agent_market.py +145 -50
  13. prediction_market_agent_tooling/markets/blockchain_utils.py +10 -1
  14. prediction_market_agent_tooling/markets/data_models.py +83 -17
  15. prediction_market_agent_tooling/markets/manifold/api.py +18 -7
  16. prediction_market_agent_tooling/markets/manifold/data_models.py +23 -16
  17. prediction_market_agent_tooling/markets/manifold/manifold.py +18 -18
  18. prediction_market_agent_tooling/markets/manifold/utils.py +7 -12
  19. prediction_market_agent_tooling/markets/markets.py +2 -1
  20. prediction_market_agent_tooling/markets/metaculus/metaculus.py +29 -4
  21. prediction_market_agent_tooling/markets/omen/data_models.py +17 -32
  22. prediction_market_agent_tooling/markets/omen/omen.py +65 -108
  23. prediction_market_agent_tooling/markets/omen/omen_contracts.py +2 -5
  24. prediction_market_agent_tooling/markets/omen/omen_resolving.py +13 -13
  25. prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +18 -12
  26. prediction_market_agent_tooling/markets/polymarket/data_models.py +7 -3
  27. prediction_market_agent_tooling/markets/polymarket/data_models_web.py +7 -3
  28. prediction_market_agent_tooling/markets/polymarket/polymarket.py +5 -4
  29. prediction_market_agent_tooling/markets/seer/data_models.py +0 -83
  30. prediction_market_agent_tooling/markets/seer/price_manager.py +44 -30
  31. prediction_market_agent_tooling/markets/seer/seer.py +105 -105
  32. prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py +34 -41
  33. prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py +1 -1
  34. prediction_market_agent_tooling/tools/cow/cow_order.py +10 -3
  35. prediction_market_agent_tooling/tools/is_predictable.py +2 -3
  36. prediction_market_agent_tooling/tools/langfuse_client_utils.py +4 -4
  37. prediction_market_agent_tooling/tools/omen/sell_positions.py +3 -2
  38. prediction_market_agent_tooling/tools/utils.py +26 -13
  39. {prediction_market_agent_tooling-0.64.12.dev659.dist-info → prediction_market_agent_tooling-0.65.0.dist-info}/METADATA +2 -2
  40. {prediction_market_agent_tooling-0.64.12.dev659.dist-info → prediction_market_agent_tooling-0.65.0.dist-info}/RECORD +43 -52
  41. prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py +0 -68
  42. prediction_market_agent_tooling/monitor/markets/manifold.py +0 -90
  43. prediction_market_agent_tooling/monitor/markets/metaculus.py +0 -43
  44. prediction_market_agent_tooling/monitor/markets/omen.py +0 -88
  45. prediction_market_agent_tooling/monitor/markets/polymarket.py +0 -49
  46. prediction_market_agent_tooling/monitor/monitor.py +0 -406
  47. prediction_market_agent_tooling/monitor/monitor_app.py +0 -149
  48. prediction_market_agent_tooling/monitor/monitor_settings.py +0 -27
  49. prediction_market_agent_tooling/tools/betting_strategies/market_moving.py +0 -146
  50. prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py +0 -12
  51. {prediction_market_agent_tooling-0.64.12.dev659.dist-info → prediction_market_agent_tooling-0.65.0.dist-info}/LICENSE +0 -0
  52. {prediction_market_agent_tooling-0.64.12.dev659.dist-info → prediction_market_agent_tooling-0.65.0.dist-info}/WHEEL +0 -0
  53. {prediction_market_agent_tooling-0.64.12.dev659.dist-info → prediction_market_agent_tooling-0.65.0.dist-info}/entry_points.txt +0 -0
@@ -5,6 +5,10 @@ from typing import Any
5
5
  from subgrounds import FieldPath
6
6
  from web3.constants import ADDRESS_ZERO
7
7
 
8
+ from prediction_market_agent_tooling.deploy.constants import (
9
+ NO_OUTCOME_LOWERCASE_IDENTIFIER,
10
+ YES_OUTCOME_LOWERCASE_IDENTIFIER,
11
+ )
8
12
  from prediction_market_agent_tooling.gtypes import ChecksumAddress
9
13
  from prediction_market_agent_tooling.loggers import logger
10
14
  from prediction_market_agent_tooling.markets.agent_market import FilterBy, SortBy
@@ -70,18 +74,11 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
70
74
  # We do an extra check for the invalid outcome for safety.
71
75
  return [m for m in markets if len(m.outcomes) == 3]
72
76
 
73
- @staticmethod
74
- def filter_binary_markets(markets: list[SeerMarket]) -> list[SeerMarket]:
75
- return [
76
- market
77
- for market in markets
78
- if {"yes", "no"}.issubset({o.lower() for o in market.outcomes})
79
- ]
80
-
81
77
  @staticmethod
82
78
  def _build_where_statements(
83
79
  filter_by: FilterBy,
84
80
  include_conditional_markets: bool = False,
81
+ include_categorical_markets: bool = True,
85
82
  ) -> dict[Any, Any]:
86
83
  now = to_int_timestamp(utcnow())
87
84
 
@@ -103,14 +100,27 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
103
100
  and_stms["parentMarket"] = ADDRESS_ZERO.lower()
104
101
 
105
102
  # We are only interested in binary markets of type YES/NO/Invalid.
106
- or_stms = {}
107
- or_stms["or"] = [
108
- {"outcomes_contains": ["YES"]},
109
- {"outcomes_contains": ["Yes"]},
110
- {"outcomes_contains": ["yes"]},
111
- ]
103
+ yes_stms, no_stms = {}, {}
104
+ if not include_categorical_markets:
105
+ # Create single OR conditions with all variations
106
+ yes_stms["or"] = [
107
+ {"outcomes_contains": [variation]}
108
+ for variation in [
109
+ YES_OUTCOME_LOWERCASE_IDENTIFIER,
110
+ YES_OUTCOME_LOWERCASE_IDENTIFIER.capitalize(),
111
+ YES_OUTCOME_LOWERCASE_IDENTIFIER.upper(),
112
+ ]
113
+ ]
114
+ no_stms["or"] = [
115
+ {"outcomes_contains": [variation]}
116
+ for variation in [
117
+ NO_OUTCOME_LOWERCASE_IDENTIFIER,
118
+ NO_OUTCOME_LOWERCASE_IDENTIFIER.capitalize(),
119
+ NO_OUTCOME_LOWERCASE_IDENTIFIER.upper(),
120
+ ]
121
+ ]
112
122
 
113
- where_stms: dict[str, t.Any] = {"and": [and_stms, or_stms]}
123
+ where_stms: dict[str, t.Any] = {"and": [and_stms, yes_stms, no_stms]}
114
124
  return where_stms
115
125
 
116
126
  def _build_sort_params(
@@ -139,18 +149,22 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
139
149
 
140
150
  return sort_direction, sort_by_field
141
151
 
142
- def get_bicategorical_markets(
152
+ def get_markets(
143
153
  self,
144
154
  filter_by: FilterBy,
155
+ sort_by: SortBy = SortBy.NONE,
145
156
  limit: int | None = None,
146
- sort_by_field: FieldPath | None = None,
147
- sort_direction: str | None = None,
148
157
  include_conditional_markets: bool = True,
158
+ include_categorical_markets: bool = True,
149
159
  ) -> list[SeerMarket]:
160
+ sort_direction, sort_by_field = self._build_sort_params(sort_by)
161
+
150
162
  """Returns markets that contain 2 categories plus an invalid outcome."""
151
163
  # Binary markets on Seer contain 3 outcomes: OutcomeA, outcomeB and an Invalid option.
152
164
  where_stms = self._build_where_statements(
153
- filter_by=filter_by, include_conditional_markets=include_conditional_markets
165
+ filter_by=filter_by,
166
+ include_conditional_markets=include_conditional_markets,
167
+ include_categorical_markets=include_categorical_markets,
154
168
  )
155
169
 
156
170
  # These values can not be set to `None`, but they can be omitted.
@@ -169,28 +183,7 @@ class SeerSubgraphHandler(BaseSubgraphHandler):
169
183
  )
170
184
  fields = self._get_fields_for_markets(markets_field)
171
185
  markets = self.do_query(fields=fields, pydantic_model=SeerMarket)
172
- two_category_markets = self.filter_bicategorical_markets(markets)
173
- return two_category_markets
174
-
175
- def get_binary_markets(
176
- self,
177
- filter_by: FilterBy,
178
- sort_by: SortBy = SortBy.NONE,
179
- limit: int | None = None,
180
- include_conditional_markets: bool = True,
181
- ) -> list[SeerMarket]:
182
- sort_direction, sort_by_field = self._build_sort_params(sort_by)
183
-
184
- two_category_markets = self.get_bicategorical_markets(
185
- limit=limit,
186
- include_conditional_markets=include_conditional_markets,
187
- sort_direction=sort_direction,
188
- sort_by_field=sort_by_field,
189
- filter_by=filter_by,
190
- )
191
- # Now we additionally filter markets based on YES/NO being the only outcomes.
192
- binary_markets = self.filter_binary_markets(two_category_markets)
193
- return binary_markets
186
+ return markets
194
187
 
195
188
  def get_market_by_id(self, market_id: HexBytes) -> SeerMarket:
196
189
  markets_field = self.seer_subgraph.Query.market(id=market_id.hex().lower())
@@ -98,7 +98,7 @@ def get_kelly_bet_full(
98
98
  check_is_valid_probability(confidence)
99
99
 
100
100
  if max_bet == 0:
101
- return SimpleBet(direction=True, size=CollateralToken(0))
101
+ return SimpleBet(size=CollateralToken(0), direction=True)
102
102
 
103
103
  x = yes_outcome_pool_size.value
104
104
  y = no_outcome_pool_size.value
@@ -3,6 +3,7 @@ from datetime import timedelta
3
3
 
4
4
  import httpx
5
5
  import tenacity
6
+ from cachetools import TTLCache, cached
6
7
  from cowdao_cowpy.common.api.errors import UnexpectedResponseError
7
8
  from cowdao_cowpy.common.chains import Chain
8
9
  from cowdao_cowpy.common.config import SupportedChainId
@@ -23,7 +24,12 @@ from cowdao_cowpy.order_book.generated.model import (
23
24
  TokenAmount,
24
25
  )
25
26
  from cowdao_cowpy.subgraph.client import BaseModel
26
- from tenacity import retry_if_not_exception_type, stop_after_attempt, wait_fixed
27
+ from tenacity import (
28
+ retry_if_not_exception_type,
29
+ stop_after_attempt,
30
+ wait_exponential,
31
+ wait_fixed,
32
+ )
27
33
  from web3 import Web3
28
34
 
29
35
  from prediction_market_agent_tooling.config import APIKeys
@@ -88,8 +94,8 @@ def get_sell_token_amount(
88
94
 
89
95
 
90
96
  @tenacity.retry(
91
- stop=stop_after_attempt(3),
92
- wait=wait_fixed(1),
97
+ stop=stop_after_attempt(4),
98
+ wait=wait_exponential(min=4, max=10),
93
99
  retry=retry_if_not_exception_type(NoLiquidityAvailableOnCowException),
94
100
  )
95
101
  def get_quote(
@@ -133,6 +139,7 @@ def get_quote(
133
139
  raise
134
140
 
135
141
 
142
+ @cached(TTLCache(maxsize=100, ttl=5 * 60))
136
143
  def get_buy_token_amount_else_raise(
137
144
  sell_amount: Wei,
138
145
  sell_token: ChecksumAddress,
@@ -15,14 +15,13 @@ from prediction_market_agent_tooling.tools.utils import (
15
15
  # I tried to make it return a JSON, but it didn't work well in combo with asking it to do chain of thought.
16
16
  QUESTION_IS_PREDICTABLE_BINARY_PROMPT = """Main signs about a fully qualified question (sometimes referred to as a "market"):
17
17
  - The market's question needs to be specific, without use of pronouns.
18
- - The market's question needs to have a clear future event.
18
+ - The market must refer to a future event — not something that already happened. This is a hard requirement. If the event has already occurred, the question is not fully qualified, even if it is specific and answerable.
19
19
  - The market's question needs to have a clear time frame.
20
20
  - The event in the market's question doesn't have to be ultra-specific, it will be decided by a crowd later on.
21
21
  - If the market's question contains date, but without an year, it's okay.
22
22
  - If the market's question contains year, but without an exact date, it's okay.
23
23
  - The market's question can not be about itself or refer to itself.
24
24
  - The answer is probably Google-able, after the event happened.
25
- - The potential answer can be only "Yes" or "No".
26
25
 
27
26
  Follow a chain of thought to evaluate if the question is fully qualified:
28
27
 
@@ -59,7 +58,7 @@ If the question is vague and the description contains the information required t
59
58
 
60
59
  Follow a chain of thought to evaluate if the question doesn't need the description to be answered.
61
60
 
62
- Start by examining detaily the question and the description. Write down their parts, what they refer to and what they contain.
61
+ Start by examining the question and the description in detail. Write down their parts, what they refer to and what they contain.
63
62
 
64
63
  Continue by writing comparison of the question and the description content. Write down what the question contains and what the description contains.
65
64
 
@@ -7,8 +7,8 @@ from pydantic import BaseModel
7
7
 
8
8
  from prediction_market_agent_tooling.loggers import logger
9
9
  from prediction_market_agent_tooling.markets.data_models import (
10
+ CategoricalProbabilisticAnswer,
10
11
  PlacedTrade,
11
- ProbabilisticAnswer,
12
12
  ResolvedBet,
13
13
  TradeType,
14
14
  )
@@ -22,7 +22,7 @@ from prediction_market_agent_tooling.tools.utils import DatetimeUTC
22
22
  class ProcessMarketTrace(BaseModel):
23
23
  timestamp: int
24
24
  market: OmenAgentMarket
25
- answer: ProbabilisticAnswer
25
+ answer: CategoricalProbabilisticAnswer
26
26
  trades: list[PlacedTrade]
27
27
 
28
28
  @property
@@ -118,10 +118,10 @@ def trace_to_omen_agent_market(trace: TraceWithDetails) -> OmenAgentMarket | Non
118
118
  return None
119
119
 
120
120
 
121
- def trace_to_answer(trace: TraceWithDetails) -> ProbabilisticAnswer:
121
+ def trace_to_answer(trace: TraceWithDetails) -> CategoricalProbabilisticAnswer:
122
122
  assert trace.output is not None, "Trace output is None"
123
123
  assert trace.output["answer"] is not None, "Trace output result is None"
124
- return ProbabilisticAnswer.model_validate(trace.output["answer"])
124
+ return CategoricalProbabilisticAnswer.model_validate(trace.output["answer"])
125
125
 
126
126
 
127
127
  def trace_to_trades(trace: TraceWithDetails) -> list[PlacedTrade]:
@@ -47,9 +47,10 @@ def sell_all(
47
47
  continue
48
48
 
49
49
  old_balance = new_balance
50
+ bet_outcome = bet.fpmm.outcomes[bet.outcomeIndex]
50
51
  agent_market.sell_tokens(
51
- bet.boolean_outcome,
52
- current_token_balance,
52
+ outcome=bet_outcome,
53
+ amount=current_token_balance,
53
54
  auto_withdraw=auto_withdraw,
54
55
  api_keys=api_keys,
55
56
  )
@@ -1,6 +1,7 @@
1
1
  import os
2
2
  import subprocess
3
3
  from datetime import datetime
4
+ from math import prod
4
5
  from typing import Any, NoReturn, Optional, Type, TypeVar
5
6
 
6
7
  import pytz
@@ -189,31 +190,43 @@ def prob_uncertainty(prob: Probability) -> float:
189
190
 
190
191
  def calculate_sell_amount_in_collateral(
191
192
  shares_to_sell: OutcomeToken,
192
- holdings: OutcomeToken,
193
- other_holdings: OutcomeToken,
193
+ outcome_index: int,
194
+ pool_balances: list[OutcomeToken],
194
195
  fees: MarketFees,
195
196
  ) -> CollateralToken:
196
197
  """
197
- Computes the amount of collateral that needs to be sold to get `shares` amount of shares.
198
+ Computes the amount of collateral that needs to be sold to get `shares`
199
+ amount of shares. Returns None if the amount can't be computed.
198
200
 
199
201
  Taken from https://github.com/protofire/omen-exchange/blob/29d0ab16bdafa5cc0d37933c1c7608a055400c73/app/src/util/tools/fpmm/trading/index.ts#L99
200
202
  Simplified for binary markets.
201
203
  """
204
+
202
205
  if shares_to_sell == 0:
203
206
  return CollateralToken(0)
204
207
 
205
- for v in [shares_to_sell, holdings, other_holdings]:
206
- if v <= 0:
207
- raise ValueError(
208
- f"All share args must be greater than 0, got {[shares_to_sell, holdings, other_holdings]=}"
209
- )
208
+ if not (0 <= outcome_index < len(pool_balances)):
209
+ raise IndexError("Invalid outcome index")
210
+
211
+ if any([v <= 0 for v in pool_balances]):
212
+ raise ValueError("All pool balances must be greater than 0")
213
+
214
+ holdings = pool_balances[outcome_index]
215
+ other_holdings = [v for i, v in enumerate(pool_balances) if i != outcome_index]
210
216
 
211
217
  def f(r: float) -> float:
212
- R = OutcomeToken((r + fees.absolute) / (1 - fees.bet_proportion))
213
- first_term = other_holdings - R
214
- second_term = holdings + shares_to_sell - R
215
- third_term = holdings * other_holdings
216
- return ((first_term * second_term) - third_term).value
218
+ R = (r + fees.absolute) / (1 - fees.bet_proportion)
219
+
220
+ # First term: product of (h_i - R) for i != outcome_index
221
+ first_term = prod(h.value - R for h in other_holdings)
222
+
223
+ # Second term: (h_o + s - R)
224
+ second_term = holdings.value + shares_to_sell.value - R
225
+
226
+ # Third term: product of all holdings (including outcome_index)
227
+ total_product = prod(h.value for h in pool_balances)
228
+
229
+ return (first_term * second_term) - total_product
217
230
 
218
231
  amount_to_sell = newton(f, 0)
219
232
  return CollateralToken(float(amount_to_sell) * 0.999999) # Avoid rounding errors
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: prediction-market-agent-tooling
3
- Version: 0.64.12.dev659
3
+ Version: 0.65.0
4
4
  Summary: Tools to benchmark, deploy and monitor prediction market agents.
5
5
  Author: Gnosis
6
6
  Requires-Python: >=3.10,<3.13
@@ -182,7 +182,7 @@ from prediction_market_agent_tooling.markets.agent_market import SortBy
182
182
  from prediction_market_agent_tooling.markets.omen.omen import OmenAgentMarket
183
183
 
184
184
  # Place a bet on the market closing soonest
185
- market = OmenAgentMarket.get_binary_markets(limit=1, sort_by=SortBy.CLOSING_SOONEST)[0]
185
+ market = OmenAgentMarket.get_markets(limit=1, sort_by=SortBy.CLOSING_SOONEST)[0]
186
186
  market.place_bet(outcome=True, amount=market.get_bet_amount(0.1))
187
187
 
188
188
  # View your positions
@@ -19,72 +19,63 @@ prediction_market_agent_tooling/abis/proxy.abi.json,sha256=h24GXZ6Q0bSZlwh7zOv0E
19
19
  prediction_market_agent_tooling/abis/seer_gnosis_router.abi.json,sha256=DyADzOXhy9MDS31ReVrG7ibpWbw1jVy19nExZ80xfRY,6839
20
20
  prediction_market_agent_tooling/abis/seer_market_factory.abi.json,sha256=g7RVxZVUWlTXIgTV2W6kO4twQM909Qv58zAr7Dk4XIc,13553
21
21
  prediction_market_agent_tooling/benchmark/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- prediction_market_agent_tooling/benchmark/agents.py,sha256=B1-uWdyeN4GGKMWGK_-CcAFJg1m9Y_XuaeIHPB29QR8,3971
23
- prediction_market_agent_tooling/benchmark/benchmark.py,sha256=MqTiaaJ3cYiOLUVR7OyImLWxcEya3Rl5JyFYW-K0lwM,17097
24
- prediction_market_agent_tooling/benchmark/utils.py,sha256=D0MfUkVZllmvcU0VOurk9tcKT7JTtwwOp-63zuCBVuc,2880
25
- prediction_market_agent_tooling/config.py,sha256=4nhDV_IkGl2-tK_yif4P3sTZm7cIvx2dWUlraSRtMwQ,10735
26
- prediction_market_agent_tooling/deploy/agent.py,sha256=dobqPUQkaDPhsvMmXwibNKu4hSSTXTvmfa3F46ylLBc,26560
27
- prediction_market_agent_tooling/deploy/agent_example.py,sha256=dIIdZashExWk9tOdyDjw87AuUcGyM7jYxNChYrVK2dM,1001
28
- prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=p25t7VU7I4hSkSl6SpzI_W55kLbYEySQdBqeschmARY,12918
29
- prediction_market_agent_tooling/deploy/constants.py,sha256=M5ty8URipYMGe_G-RzxRydK3AFL6CyvmqCraJUrLBnE,82
22
+ prediction_market_agent_tooling/benchmark/agents.py,sha256=zC5tUM6pPTWtqSddOOSYV_fxHYmZb5uGAb4Ru87Tah8,4221
23
+ prediction_market_agent_tooling/benchmark/benchmark.py,sha256=KwMZzwise3sgmhdjw7xCgHMmjKHdHqQC-zc9untOLWg,17832
24
+ prediction_market_agent_tooling/benchmark/utils.py,sha256=xQd7p9H08-OtN3iC4QT2i9bkUTmrXa6rxGXeg9yMhgU,2986
25
+ prediction_market_agent_tooling/chains.py,sha256=1qQstoqXMwqwM7k-KH7MjMz8Ei-D83KZByvDbCZpAxs,116
26
+ prediction_market_agent_tooling/config.py,sha256=rdpRHZyoTvRIDn7Qu6eViOjPBkR9Z0MOdEMFsQOuAIE,10822
27
+ prediction_market_agent_tooling/deploy/agent.py,sha256=kxfJNfuvGJ2LFReI-PCyjGuubZKIrPEYiyphaS6eKcM,25476
28
+ prediction_market_agent_tooling/deploy/agent_example.py,sha256=yS1fWkHynr9MYGNOM2WsCnRWLPaffY4bOc6bIudrdd4,1377
29
+ prediction_market_agent_tooling/deploy/betting_strategy.py,sha256=YYayGjTKW02d3BUavJ8M3NmFk41oldEM3FHbwppZGRM,17184
30
+ prediction_market_agent_tooling/deploy/constants.py,sha256=Qe9cllgsGMkecfmbhXoFkPxuJyG6ATsrT87RF9SmPWM,249
30
31
  prediction_market_agent_tooling/deploy/gcp/deploy.py,sha256=CYUgnfy-9XVk04kkxA_5yp0GE9Mw5caYqlFUZQ2j3ks,3739
31
32
  prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py,sha256=OsPboCFGiZKsvGyntGZHwdqPlLTthITkNF5rJFvGgU8,2582
32
33
  prediction_market_agent_tooling/deploy/gcp/utils.py,sha256=WI2ycX1X-IlTRoNoG4ggFlRwPL28kwM9VGDFD2fePLo,5699
33
34
  prediction_market_agent_tooling/deploy/trade_interval.py,sha256=Xk9j45alQ_vrasGvsNyuW70XHIQ7wfvjoxNR3F6HYCw,1155
34
35
  prediction_market_agent_tooling/gtypes.py,sha256=bUIZfZIGvIi3aiZNu5rVE9kRevw8sfMa4bcze6QeBg8,6058
35
36
  prediction_market_agent_tooling/jobs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
- prediction_market_agent_tooling/jobs/jobs_models.py,sha256=8vYafsK1cqMWQtjBoq9rruroF84xAVD00vBTMWH6QMg,2166
37
- prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=Pf6QxPXGyie-2l_wZUjaGPTjZTlpv50_JhP40mULBaU,5048
37
+ prediction_market_agent_tooling/jobs/jobs_models.py,sha256=DoZ9dlvVhpNrnINiR1uy6YUOsuzI_L-avBt362y5xXM,2467
38
+ prediction_market_agent_tooling/jobs/omen/omen_jobs.py,sha256=qbTZ9HVvu_iP4dDxuvOZxAp6JsRKejvEW2YDYCnRmd4,5039
38
39
  prediction_market_agent_tooling/loggers.py,sha256=hF_n-E5iMSqh3dY5G6LkQRHyReMYGPNTLu82dDFh1PU,5187
39
40
  prediction_market_agent_tooling/logprobs_parser.py,sha256=Du1Yc-fAVSixQX_Zx6KWpgSzI_ZYhv5tS1b8IcOPPr8,4979
40
- prediction_market_agent_tooling/markets/agent_market.py,sha256=1NomilM0GCXcRq_1N_cr2AbSK5ONTowFeRbrhc7V5zE,14929
41
+ prediction_market_agent_tooling/markets/agent_market.py,sha256=smKuMaP1zyTtw31Robbj3ospF03xptWX0EDKPJbHH9I,19070
41
42
  prediction_market_agent_tooling/markets/base_subgraph_handler.py,sha256=7RaYO_4qAmQ6ZGM8oPK2-CkiJfKmV9MxM-rJlduaecU,1971
42
- prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=qm21scopQ6dfewkoqQF6lWLDGg2BblsKUdC9aG93Hmc,2249
43
+ prediction_market_agent_tooling/markets/blockchain_utils.py,sha256=gZMwCTO-1d2ALXeY7-LP6U4kCpotJ6GMPZwN11kFOfE,2604
43
44
  prediction_market_agent_tooling/markets/categorize.py,sha256=jsoHWvZk9pU6n17oWSCcCxNNYVwlb_NXsZxKRI7vmsk,1301
44
- prediction_market_agent_tooling/markets/data_models.py,sha256=OZdq7VfTenxPk_3mI7DvpGMFMBPrq2pvFwcMb47BnNY,4663
45
+ prediction_market_agent_tooling/markets/data_models.py,sha256=vFlX1iNWJcYZlImPkTOQCp2C0veIO7HuAxe0Wf_S8yg,6952
45
46
  prediction_market_agent_tooling/markets/manifold/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
- prediction_market_agent_tooling/markets/manifold/api.py,sha256=ih92UTZdSbmy6tTUgSCps_HqYQXpMSsfne5Np5znVEM,7217
47
- prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=DWNvK6Qdxz7Lxqpe-qQE4X-mw8GFGpukGfnjT_ohcZA,6364
48
- prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=TakZ0SqyDFal0QECKCkKkuqqeUm1o3mTpesQIuYInig,4800
49
- prediction_market_agent_tooling/markets/manifold/utils.py,sha256=_gGlWid0sPF127Omx5qQ1fq17frLInv0wdyXJBMGVzM,670
47
+ prediction_market_agent_tooling/markets/manifold/api.py,sha256=tWnjuqvU8pcCuja2B_ynHeds1iiEFc6QWHjeSO_GSxY,7676
48
+ prediction_market_agent_tooling/markets/manifold/data_models.py,sha256=QzRfR2g_3vzCw4azj_lOSKSFAZczjAWlM0lQy2dZry8,6704
49
+ prediction_market_agent_tooling/markets/manifold/manifold.py,sha256=dUVBkTqnD7M35H20nvSFG6dalYi9CbYZ8cyAqEMz9AE,4700
50
+ prediction_market_agent_tooling/markets/manifold/utils.py,sha256=aprL6vd4xZjzRDRyuhKkw5MnjPNFvwoqjDGLu9XoLXQ,361
50
51
  prediction_market_agent_tooling/markets/market_fees.py,sha256=YeK3ynjYIguB0xf6sO5iyg9lOdW_HD4C6nbJfiGyRCU,1351
51
- prediction_market_agent_tooling/markets/markets.py,sha256=Aseaflknwqsqg6wsCSnWU2Aoc5jH4g0aomnCI3VYRRU,4125
52
+ prediction_market_agent_tooling/markets/markets.py,sha256=cXN37xnNNOFJUcdmfD9osrGiffTxGVzWVNUFAPyPGkc,4119
52
53
  prediction_market_agent_tooling/markets/metaculus/api.py,sha256=4TRPGytQQbSdf42DCg2M_JWYPAuNjqZ3eBqaQBLkNks,2736
53
54
  prediction_market_agent_tooling/markets/metaculus/data_models.py,sha256=FaBCTPPezXbBwZ9p791CiVgQ4vB696xnMbz9XVXmiVI,3267
54
- prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=86TIx6cavEWc8Cv4KpZxSvwiSw9oFybXE3YB49pg-CA,4377
55
+ prediction_market_agent_tooling/markets/metaculus/metaculus.py,sha256=6iuUpDXgdbFOh-XuxH0rbeAf_m55r2KbHTaSTePNSWA,5614
55
56
  prediction_market_agent_tooling/markets/omen/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
56
57
  prediction_market_agent_tooling/markets/omen/cow_contracts.py,sha256=sl1L4cK5nAJwZ2wdhLzqh8p7h_IEValNvLwKUlInKxw,957
57
- prediction_market_agent_tooling/markets/omen/data_models.py,sha256=4YEOpU-ypq8IBxlEr_qgrKKWwE7wKG6VE_Dq-UKVdOE,30513
58
- prediction_market_agent_tooling/markets/omen/omen.py,sha256=NKeTT2gU6uZ9a4gGpa9Dxy6msFQp_41Ug85hIdCmQy4,51733
58
+ prediction_market_agent_tooling/markets/omen/data_models.py,sha256=0jCxgUEVpaggt_avkNqgXAnZWdA6D-ew9PE2gm0aqDk,29930
59
+ prediction_market_agent_tooling/markets/omen/omen.py,sha256=jyoAV-E_Qcbqqs4oi7junE3rHTG3kaYLMtIVzEkNC6M,49981
59
60
  prediction_market_agent_tooling/markets/omen/omen_constants.py,sha256=D9oflYKafLQiHYtB5sScMHqmXyzM8JP8J0yATmc4SQQ,233
60
- prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=c6Z-hZzOybnmU-xRgzKElZmy_238Mf2mQ6dSUaYP_tY,29834
61
- prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=Cyi9Ci-Z-K8WCZWVLs9oSuJC6qRobi_CpqDCno_5F-0,10238
62
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=j-x_0Cm8IO-qynIXutu0iSPwrRDxdeCPYf5UHm6MJbs,39446
61
+ prediction_market_agent_tooling/markets/omen/omen_contracts.py,sha256=f0dKbdVM2OUTSpkCSZdPtKqeckS2c48j3rjnK8oD3wE,29716
62
+ prediction_market_agent_tooling/markets/omen/omen_resolving.py,sha256=05x-Yb0bUsJSEtsWQLqSHyl4HqLChksIb64OGygN-Rw,10226
63
+ prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py,sha256=ONwcLinp4uzlvLGmDDtGcE7_zrFoDVBTNshrYtw3ffk,39678
63
64
  prediction_market_agent_tooling/markets/polymarket/api.py,sha256=UZ4_TG8ceb9Y-qgsOKs8Qiv8zDt957QkT8IX2c83yqo,4800
64
- prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=utGN-Lhjsa-RHX5WW_jcqgWXtRkEZn0JemwYZkt3Lng,4344
65
- prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=LVEsNw2nUx5poiU1m803NNqG5-fs8-MODQRyGLqy4mE,12585
66
- prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=6rc9qulPl90MxXKB55XiiWKLhjfAyG_eUzAlqpq1UIE,3339
65
+ prediction_market_agent_tooling/markets/polymarket/data_models.py,sha256=U1SXTz93FIG3GO1h5BJWSt1hPKn_YAMBeZ3k8IS-ook,4552
66
+ prediction_market_agent_tooling/markets/polymarket/data_models_web.py,sha256=wCwpZ8Kppy8JG_1HZDfEK_Gg1g1sL7NCbGoPeTeMSko,12756
67
+ prediction_market_agent_tooling/markets/polymarket/polymarket.py,sha256=meAhQ5_gwVDvlSxhGGVAvRB7B47zKLnRvZ-_13tKtwY,3433
67
68
  prediction_market_agent_tooling/markets/polymarket/utils.py,sha256=8kTeVjXPcXC6DkDvWYsZQLY7x8DS6CEp_yznSEazsNU,2037
68
- prediction_market_agent_tooling/markets/seer/data_models.py,sha256=TcsDgbk2id1JJ_XT9bnvO4M75dTvOtbzQX67918OQ8E,7442
69
- prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=EuOe6zCmEEWXz1loXaQQOYC7ZNQ0cDJn0rZadK1dBlc,5460
70
- prediction_market_agent_tooling/markets/seer/seer.py,sha256=fx2daHPKRXXNsQYFKI8S0x879WX4FM7uSFAmf2AGWXI,20608
69
+ prediction_market_agent_tooling/markets/seer/data_models.py,sha256=G0i-fnVaK16KWDYVI6w3lvyte6Op7ca_iIC8IfrXmlM,4702
70
+ prediction_market_agent_tooling/markets/seer/price_manager.py,sha256=ciplVu2BnI9D9REq9x9cVlBLlzhzZSMmNWTulfO2YRg,5787
71
+ prediction_market_agent_tooling/markets/seer/seer.py,sha256=5uSKUhyM_3PTguYi9yiD3-E5Famb6M_fayBX1NqebAE,20273
71
72
  prediction_market_agent_tooling/markets/seer/seer_contracts.py,sha256=kH9nPXsx6UM5er42g2f3fLvy36sY5JM2f_beXeuNgUc,3790
72
- prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=KKRI493VNNAY9tR1AjzNraeH76MvDsBV6GsiLZas0_Y,9859
73
+ prediction_market_agent_tooling/markets/seer/seer_subgraph_handler.py,sha256=v7gOlRRsbj1xpQiz3D3TE6gbO8_Itg2xhPeTqU9DBsc,9701
73
74
  prediction_market_agent_tooling/markets/seer/subgraph_data_models.py,sha256=0izxS8Mtzonfdl9UqvFVXrdj0hVzieroekXhogfZKCw,1817
74
- prediction_market_agent_tooling/monitor/financial_metrics/financial_metrics.py,sha256=fjIgjDIx5MhH5mwf7S0cspLOOSU3elYLhGYoIiM26mU,2746
75
- prediction_market_agent_tooling/monitor/markets/manifold.py,sha256=TS4ERwTfQnot8dhekNyVNhJYf5ysYsjF-9v5_kM3aVI,3334
76
- prediction_market_agent_tooling/monitor/markets/metaculus.py,sha256=LOnyWWBFdg10-cTWdb76nOsNjDloO8OfMT85GBzRCFI,1455
77
- prediction_market_agent_tooling/monitor/markets/omen.py,sha256=EqiJYTvDbSu7fBpbrBmCuf3fc6GHr4MxWrBGa69MIyc,3305
78
- prediction_market_agent_tooling/monitor/markets/polymarket.py,sha256=wak8o4BYaGbLpshQD12OrsqNABdanyID6ql95lEG2io,1870
79
- prediction_market_agent_tooling/monitor/monitor.py,sha256=yvSXwV-3DSAm3vsFZnFC9jEQzlaB9KUOxI6pOyNKGQk,14147
80
- prediction_market_agent_tooling/monitor/monitor_app.py,sha256=-_6w_ZvQ-Ad5qaeuo7NKTXUOOZ_6OrR8jMe25BGOY4k,4615
81
- prediction_market_agent_tooling/monitor/monitor_settings.py,sha256=Xiozs3AsufuJ04JOe1vjUri-IAMWHjjmc2ugGGiHNH4,947
82
75
  prediction_market_agent_tooling/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
83
76
  prediction_market_agent_tooling/tools/_generic_value.py,sha256=pD_PI13lpPp1gFoljHwa_Lzlp-u2pu0m-Z7LcxwDM2U,10618
84
77
  prediction_market_agent_tooling/tools/balances.py,sha256=Osab21btfJDw2Y-jT_TV-KHGrseCRxcsYeW6WcOMB8E,1050
85
- prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py,sha256=L9yp3m_81i-y85dGZH1rYRv9YXYYt1w3RGroFAAYSbw,4873
86
- prediction_market_agent_tooling/tools/betting_strategies/market_moving.py,sha256=36ucOuF38bdB4rnSPNjC1qpidBo30Ff4P5Kb-7emKEQ,5469
87
- prediction_market_agent_tooling/tools/betting_strategies/minimum_bet_to_win.py,sha256=-FUSuQQgjcWSSnoFxnlAyTeilY6raJABJVM2QKkFqAY,438
78
+ prediction_market_agent_tooling/tools/betting_strategies/kelly_criterion.py,sha256=duylr4I06L0-Vpeomatzt3_dxs6bijt41TJPwm1YjRg,4873
88
79
  prediction_market_agent_tooling/tools/betting_strategies/stretch_bet_between.py,sha256=THMXwFlskvzbjnX_OiYtDSzI8XVFyULWfP2525_9UGc,429
89
80
  prediction_market_agent_tooling/tools/betting_strategies/utils.py,sha256=68zFWUj43GUaSpOPowVrbI-t6qbCE29RsVHNzCVuJ9U,175
90
81
  prediction_market_agent_tooling/tools/caches/db_cache.py,sha256=rZIGhgijquwwPtp_qncSAPR1SDF2XxIVZL1ir0fgzWw,12127
@@ -92,7 +83,7 @@ prediction_market_agent_tooling/tools/caches/inmemory_cache.py,sha256=ZW5iI5rmjq
92
83
  prediction_market_agent_tooling/tools/caches/serializers.py,sha256=vFDx4fsPxclXp2q0sv27j4al_M_Tj9aR2JJP-xNHQXA,2151
93
84
  prediction_market_agent_tooling/tools/contract.py,sha256=pdr9ZYmj4QVUfgVKdvOU6ucYdBpJGdha_FMR_LgtcEs,22912
94
85
  prediction_market_agent_tooling/tools/costs.py,sha256=EaAJ7v9laD4VEV3d8B44M4u3_oEO_H16jRVCdoZ93Uw,954
95
- prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=nZafUa5d23mFnEL2arm3jLdqdA9zl-z_fN39ceovwg4,9079
86
+ prediction_market_agent_tooling/tools/cow/cow_order.py,sha256=-nuV2rrLKWKnMn7mN3knRdRemwGiq46OY6m6jX4sm7c,9219
96
87
  prediction_market_agent_tooling/tools/custom_exceptions.py,sha256=Fh8z1fbwONvP4-j7AmV_PuEcoqb6-QXa9PJ9m7guMcM,93
97
88
  prediction_market_agent_tooling/tools/datetime_utc.py,sha256=8_WackjtjC8zHXrhQFTGQ6e6Fz_6llWoKR4CSFvIv9I,2766
98
89
  prediction_market_agent_tooling/tools/db/db_manager.py,sha256=GtzHH1NLl8HwqC8Z7s6eTlIQXuV0blxfaV2PeQrBnfQ,3013
@@ -103,11 +94,11 @@ prediction_market_agent_tooling/tools/image_gen/image_gen.py,sha256=i7ole0NMprEL
103
94
  prediction_market_agent_tooling/tools/image_gen/market_thumbnail_gen.py,sha256=jgOow4zw6g8dIJrog6Tp-3NQs4wjUJ3VgVKyMQv-0QM,1286
104
95
  prediction_market_agent_tooling/tools/ipfs/ipfs_handler.py,sha256=CTTMfTvs_8PH4kAtlQby2aeEKwgpmxtuGbd4oYIdJ2A,1201
105
96
  prediction_market_agent_tooling/tools/is_invalid.py,sha256=TAHQXiiusAU45xJ11ZyEP7PnEfcjfzVG7qHRbsHiAd0,5335
106
- prediction_market_agent_tooling/tools/is_predictable.py,sha256=qVd6zqay2Dg2fyeAuZvAFqSHMg71TcPfCZULsVk2XvA,6797
97
+ prediction_market_agent_tooling/tools/is_predictable.py,sha256=gAis7mrHeK5RwMERYR9QJb2rF7lHvCxL6hlOrswSqSo,6911
107
98
  prediction_market_agent_tooling/tools/langfuse_.py,sha256=jI_4ROxqo41CCnWGS1vN_AeDVhRzLMaQLxH3kxDu3L8,1153
108
- prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=636bHCxwfWSbQYQQ0ipeyJUDXCbAC1zP6ZqzeLL2GJk,6582
99
+ prediction_market_agent_tooling/tools/langfuse_client_utils.py,sha256=6IvsqqNNfBtwonAqcdhkDi-GN0pMS8dID3vFGUZoEoM,6626
109
100
  prediction_market_agent_tooling/tools/omen/reality_accuracy.py,sha256=M1SF7iSW1gVlQSTskdVFTn09uPLST23YeipVIWj54io,2236
110
- prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=7b2qHGQ_2V3ke_UTR9wQeJW88z5ub1GTre9Y_zd4e9E,2387
101
+ prediction_market_agent_tooling/tools/omen/sell_positions.py,sha256=Q4oI7_QI3AkyxlH10VvxDahYVrphQa1Wnox2Ce_cf_k,2452
111
102
  prediction_market_agent_tooling/tools/parallelism.py,sha256=6Gou0hbjtMZrYvxjTDFUDZuxmE2nqZVbb6hkg1hF82A,1022
112
103
  prediction_market_agent_tooling/tools/relevant_news_analysis/data_models.py,sha256=95l84aztFaxcRLLcRQ46yKJbIlOEuDAbIGLouyliDzA,1316
113
104
  prediction_market_agent_tooling/tools/relevant_news_analysis/relevant_news_analysis.py,sha256=CddJem7tk15NAudJDwmuL8znTycbR-YI8kTNtd3LzG8,5474
@@ -123,10 +114,10 @@ prediction_market_agent_tooling/tools/tokens/main_token.py,sha256=1rbwpdCusPgQIV
123
114
  prediction_market_agent_tooling/tools/tokens/token_utils.py,sha256=fhs-FH9m9IbzGa-30R3ZleSKLeKfLEDoJ7F5Om285Vk,1369
124
115
  prediction_market_agent_tooling/tools/tokens/usd.py,sha256=yuW8iPPtcpP4eLH2nORMDAfztcq0Nv2ascSrCquF1f8,3115
125
116
  prediction_market_agent_tooling/tools/transaction_cache.py,sha256=K5YKNL2_tR10Iw2TD9fuP-CTGpBbZtNdgbd0B_R7pjg,1814
126
- prediction_market_agent_tooling/tools/utils.py,sha256=AC2a68jwASMWuQi-w8twl8b_M52YwrEJ81abmuEaqMY,6661
117
+ prediction_market_agent_tooling/tools/utils.py,sha256=Jzpck3_QwShhejhgbAhmNxPSOPQJssBQep0eVemVjZ4,7064
127
118
  prediction_market_agent_tooling/tools/web3_utils.py,sha256=zRq-eeBGWt8uUGN9G_WfjmJ0eVvO8aWE9S0Pz_Y6AOA,12342
128
- prediction_market_agent_tooling-0.64.12.dev659.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
129
- prediction_market_agent_tooling-0.64.12.dev659.dist-info/METADATA,sha256=h5X6hcjazmTczUeSjQ1AhZV9ti-Ygp_OWmMkENcSLXY,8749
130
- prediction_market_agent_tooling-0.64.12.dev659.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
131
- prediction_market_agent_tooling-0.64.12.dev659.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
132
- prediction_market_agent_tooling-0.64.12.dev659.dist-info/RECORD,,
119
+ prediction_market_agent_tooling-0.65.0.dist-info/LICENSE,sha256=6or154nLLU6bELzjh0mCreFjt0m2v72zLi3yHE0QbeE,7650
120
+ prediction_market_agent_tooling-0.65.0.dist-info/METADATA,sha256=y1MAlJYLGomNEXjCKul5qGed38uRLULoYAtzh-xFZ2E,8734
121
+ prediction_market_agent_tooling-0.65.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
122
+ prediction_market_agent_tooling-0.65.0.dist-info/entry_points.txt,sha256=m8PukHbeH5g0IAAmOf_1Ahm-sGAMdhSSRQmwtpmi2s8,81
123
+ prediction_market_agent_tooling-0.65.0.dist-info/RECORD,,
@@ -1,68 +0,0 @@
1
- import numpy as np
2
- import pandas as pd
3
-
4
- from prediction_market_agent_tooling.markets.data_models import (
5
- SharpeOutput,
6
- SimulatedBetDetail,
7
- )
8
-
9
-
10
- class SharpeRatioCalculator:
11
- def __init__(
12
- self, details: list[SimulatedBetDetail], risk_free_rate: float = 0.0
13
- ) -> None:
14
- self.details = details
15
- self.df = pd.DataFrame([d.model_dump() for d in self.details])
16
- self.risk_free_rate = risk_free_rate
17
-
18
- def __has_df_valid_columns_else_exception(
19
- self, required_columns: list[str]
20
- ) -> None:
21
- if not set(required_columns).issubset(self.df.columns):
22
- raise ValueError(
23
- f"Dataframe doesn't contain all the required columns. {required_columns=} {self.df.columns=}"
24
- )
25
-
26
- def prepare_wallet_daily_balance_df(
27
- self, timestamp_col_name: str, profit_col_name: str
28
- ) -> pd.DataFrame:
29
- self.__has_df_valid_columns_else_exception(
30
- [timestamp_col_name, profit_col_name]
31
- )
32
- df = self.df.copy()
33
- df[timestamp_col_name] = pd.to_datetime(df[timestamp_col_name])
34
- df.sort_values(timestamp_col_name, ascending=True, inplace=True)
35
-
36
- df["profit_cumsum"] = df[profit_col_name].cumsum()
37
- df["profit_cumsum"] = df["profit_cumsum"] + 50
38
-
39
- df = df.drop_duplicates(subset=timestamp_col_name, keep="last")
40
- df.set_index(timestamp_col_name, inplace=True)
41
- # We generate a new Dataframe with daily wallet balances, derived by the final wallet balance
42
- # from the previous day.
43
- wallet_balance_daily_df = df[["profit_cumsum"]].resample("D").ffill()
44
- wallet_balance_daily_df.dropna(inplace=True)
45
- wallet_balance_daily_df["returns"] = wallet_balance_daily_df[
46
- "profit_cumsum"
47
- ].pct_change()
48
- return wallet_balance_daily_df
49
-
50
- def calculate_annual_sharpe_ratio(
51
- self, timestamp_col_name: str = "timestamp", profit_col_name: str = "sim_profit"
52
- ) -> SharpeOutput:
53
- wallet_daily_balance_df = self.prepare_wallet_daily_balance_df(
54
- timestamp_col_name=timestamp_col_name, profit_col_name=profit_col_name
55
- )
56
-
57
- daily_volatility = wallet_daily_balance_df["returns"].std()
58
- annualized_volatility = daily_volatility * np.sqrt(365)
59
- mean_daily_return = wallet_daily_balance_df["returns"].mean()
60
- daily_sharpe_ratio = (
61
- mean_daily_return - self.risk_free_rate
62
- ) / daily_volatility
63
- annualized_sharpe_ratio = daily_sharpe_ratio * np.sqrt(365)
64
- return SharpeOutput(
65
- annualized_volatility=annualized_volatility,
66
- mean_daily_return=mean_daily_return,
67
- annualized_sharpe_ratio=annualized_sharpe_ratio,
68
- )
@@ -1,90 +0,0 @@
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.markets.data_models import ResolvedBet
8
- from prediction_market_agent_tooling.markets.manifold.api import (
9
- get_authenticated_user,
10
- get_resolved_manifold_bets,
11
- manifold_to_generic_resolved_bet,
12
- )
13
- from prediction_market_agent_tooling.markets.markets import MarketType
14
- from prediction_market_agent_tooling.monitor.monitor import (
15
- DeployedAgent,
16
- KubernetesCronJob,
17
- )
18
- from prediction_market_agent_tooling.tools.utils import DatetimeUTC
19
-
20
-
21
- class DeployedManifoldAgent(DeployedAgent):
22
- manifold_user_id: str
23
-
24
- @property
25
- def public_id(self) -> str:
26
- return self.manifold_user_id
27
-
28
- def get_resolved_bets(self) -> list[ResolvedBet]:
29
- bets, markets = get_resolved_manifold_bets(
30
- user_id=self.manifold_user_id,
31
- start_time=self.start_time,
32
- end_time=self.end_time,
33
- )
34
- return [manifold_to_generic_resolved_bet(b, m) for b, m in zip(bets, markets)]
35
-
36
- @classmethod
37
- def from_env_vars_without_prefix(
38
- cls: t.Type["DeployedManifoldAgent"],
39
- env_vars: dict[str, t.Any] | None = None,
40
- extra_vars: dict[str, t.Any] | None = None,
41
- ) -> "DeployedManifoldAgent":
42
- # If manifold_user_id is not provided, try to use it from APIKeys initialized from env_vars (will work in case that secret manifold api key was in the env).
43
- api_keys = APIKeys(**env_vars) if env_vars else None
44
- if (
45
- env_vars
46
- and "manifold_user_id" not in env_vars
47
- and api_keys
48
- and api_keys.MANIFOLD_API_KEY is not None
49
- and api_keys.MANIFOLD_API_KEY
50
- != APIKeys().MANIFOLD_API_KEY # Check that it didn't get if from the default env.
51
- ):
52
- env_vars["manifold_user_id"] = api_keys.manifold_user_id
53
- return super().from_env_vars_without_prefix(
54
- env_vars=env_vars, extra_vars=extra_vars
55
- )
56
-
57
- @staticmethod
58
- def from_api_keys(
59
- name: str,
60
- start_time: DatetimeUTC,
61
- api_keys: APIKeys,
62
- ) -> "DeployedManifoldAgent":
63
- return DeployedManifoldAgent(
64
- name=name,
65
- start_time=start_time,
66
- manifold_user_id=get_authenticated_user(
67
- api_key=api_keys.manifold_api_key.get_secret_value()
68
- ).id,
69
- )
70
-
71
- @classmethod
72
- def from_all_gcp_functions(
73
- cls: t.Type["DeployedManifoldAgent"],
74
- filter_: t.Callable[[Function], bool] = lambda function: function.labels[
75
- MARKET_TYPE_KEY
76
- ]
77
- == MarketType.MANIFOLD.value,
78
- ) -> t.Sequence["DeployedManifoldAgent"]:
79
- return super().from_all_gcp_functions(filter_=filter_)
80
-
81
- @classmethod
82
- def from_all_gcp_cronjobs(
83
- cls: t.Type["DeployedManifoldAgent"],
84
- namespace: str,
85
- filter_: t.Callable[
86
- [KubernetesCronJob], bool
87
- ] = lambda cronjob: cronjob.metadata.labels[MARKET_TYPE_KEY]
88
- == MarketType.MANIFOLD.value,
89
- ) -> t.Sequence["DeployedManifoldAgent"]:
90
- return super().from_all_gcp_cronjobs(namespace=namespace, filter_=filter_)