prediction-market-agent-tooling 0.49.2__py3-none-any.whl → 0.50.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 +6 -6
- prediction_market_agent_tooling/deploy/agent.py +4 -4
- prediction_market_agent_tooling/deploy/gcp/kubernetes_models.py +3 -4
- prediction_market_agent_tooling/gtypes.py +3 -2
- prediction_market_agent_tooling/jobs/jobs_models.py +3 -3
- prediction_market_agent_tooling/jobs/omen/omen_jobs.py +2 -2
- prediction_market_agent_tooling/markets/agent_market.py +11 -17
- prediction_market_agent_tooling/markets/data_models.py +3 -3
- prediction_market_agent_tooling/markets/manifold/api.py +6 -6
- prediction_market_agent_tooling/markets/manifold/data_models.py +13 -23
- prediction_market_agent_tooling/markets/manifold/manifold.py +2 -2
- prediction_market_agent_tooling/markets/markets.py +7 -3
- prediction_market_agent_tooling/markets/metaculus/api.py +2 -3
- prediction_market_agent_tooling/markets/metaculus/data_models.py +11 -10
- prediction_market_agent_tooling/markets/metaculus/metaculus.py +2 -2
- prediction_market_agent_tooling/markets/omen/data_models.py +35 -22
- prediction_market_agent_tooling/markets/omen/omen.py +11 -8
- prediction_market_agent_tooling/markets/omen/omen_contracts.py +3 -2
- prediction_market_agent_tooling/markets/omen/omen_resolving.py +2 -3
- prediction_market_agent_tooling/markets/omen/omen_subgraph_handler.py +36 -33
- prediction_market_agent_tooling/markets/polymarket/data_models.py +5 -6
- prediction_market_agent_tooling/markets/polymarket/data_models_web.py +14 -14
- prediction_market_agent_tooling/markets/polymarket/polymarket.py +2 -2
- prediction_market_agent_tooling/monitor/markets/manifold.py +2 -2
- prediction_market_agent_tooling/monitor/markets/metaculus.py +2 -2
- prediction_market_agent_tooling/monitor/markets/omen.py +2 -2
- prediction_market_agent_tooling/monitor/markets/polymarket.py +2 -2
- prediction_market_agent_tooling/monitor/monitor.py +5 -15
- prediction_market_agent_tooling/monitor/monitor_app.py +7 -8
- prediction_market_agent_tooling/tools/contract.py +3 -7
- prediction_market_agent_tooling/tools/datetime_utc.py +74 -0
- prediction_market_agent_tooling/tools/langfuse_client_utils.py +16 -11
- prediction_market_agent_tooling/tools/tavily_storage/tavily_models.py +4 -4
- prediction_market_agent_tooling/tools/utils.py +28 -52
- {prediction_market_agent_tooling-0.49.2.dist-info → prediction_market_agent_tooling-0.50.0.dist-info}/METADATA +4 -2
- {prediction_market_agent_tooling-0.49.2.dist-info → prediction_market_agent_tooling-0.50.0.dist-info}/RECORD +39 -38
- {prediction_market_agent_tooling-0.49.2.dist-info → prediction_market_agent_tooling-0.50.0.dist-info}/LICENSE +0 -0
- {prediction_market_agent_tooling-0.49.2.dist-info → prediction_market_agent_tooling-0.50.0.dist-info}/WHEEL +0 -0
- {prediction_market_agent_tooling-0.49.2.dist-info → prediction_market_agent_tooling-0.50.0.dist-info}/entry_points.txt +0 -0
@@ -1,7 +1,5 @@
|
|
1
1
|
import typing as t
|
2
|
-
from datetime import datetime
|
3
2
|
|
4
|
-
import pytz
|
5
3
|
from pydantic import BaseModel, ConfigDict, Field, computed_field
|
6
4
|
from web3 import Web3
|
7
5
|
|
@@ -26,6 +24,7 @@ from prediction_market_agent_tooling.markets.data_models import (
|
|
26
24
|
ResolvedBet,
|
27
25
|
)
|
28
26
|
from prediction_market_agent_tooling.tools.utils import (
|
27
|
+
DatetimeUTC,
|
29
28
|
check_not_none,
|
30
29
|
should_not_happen,
|
31
30
|
)
|
@@ -71,7 +70,7 @@ class Question(BaseModel):
|
|
71
70
|
outcomes: list[str]
|
72
71
|
isPendingArbitration: bool
|
73
72
|
openingTimestamp: int
|
74
|
-
answerFinalizedTimestamp: t.Optional[
|
73
|
+
answerFinalizedTimestamp: t.Optional[DatetimeUTC] = None
|
75
74
|
currentAnswer: t.Optional[str] = None
|
76
75
|
|
77
76
|
@property
|
@@ -84,8 +83,8 @@ class Question(BaseModel):
|
|
84
83
|
return len(self.outcomes)
|
85
84
|
|
86
85
|
@property
|
87
|
-
def opening_datetime(self) ->
|
88
|
-
return
|
86
|
+
def opening_datetime(self) -> DatetimeUTC:
|
87
|
+
return DatetimeUTC.to_datetime_utc(self.openingTimestamp)
|
89
88
|
|
90
89
|
@property
|
91
90
|
def has_answer(self) -> bool:
|
@@ -218,11 +217,11 @@ class OmenMarket(BaseModel):
|
|
218
217
|
return self.question.openingTimestamp
|
219
218
|
|
220
219
|
@property
|
221
|
-
def opening_datetime(self) ->
|
222
|
-
return
|
220
|
+
def opening_datetime(self) -> DatetimeUTC:
|
221
|
+
return DatetimeUTC.to_datetime_utc(self.openingTimestamp)
|
223
222
|
|
224
223
|
@property
|
225
|
-
def close_time(self) ->
|
224
|
+
def close_time(self) -> DatetimeUTC:
|
226
225
|
# Opening of the Reality's question is close time for the market,
|
227
226
|
# however, market is usually "closed" even sooner by removing all the liquidity.
|
228
227
|
return self.opening_datetime
|
@@ -257,13 +256,13 @@ class OmenMarket(BaseModel):
|
|
257
256
|
return self.title
|
258
257
|
|
259
258
|
@property
|
260
|
-
def creation_datetime(self) ->
|
261
|
-
return
|
259
|
+
def creation_datetime(self) -> DatetimeUTC:
|
260
|
+
return DatetimeUTC.to_datetime_utc(self.creationTimestamp)
|
262
261
|
|
263
262
|
@property
|
264
|
-
def finalized_datetime(self) ->
|
263
|
+
def finalized_datetime(self) -> DatetimeUTC | None:
|
265
264
|
return (
|
266
|
-
|
265
|
+
DatetimeUTC.to_datetime_utc(self.answerFinalizedTimestamp)
|
267
266
|
if self.answerFinalizedTimestamp is not None
|
268
267
|
else None
|
269
268
|
)
|
@@ -490,8 +489,8 @@ class OmenBet(BaseModel):
|
|
490
489
|
fpmm: OmenMarket
|
491
490
|
|
492
491
|
@property
|
493
|
-
def creation_datetime(self) ->
|
494
|
-
return
|
492
|
+
def creation_datetime(self) -> DatetimeUTC:
|
493
|
+
return DatetimeUTC.to_datetime_utc(self.creationTimestamp)
|
495
494
|
|
496
495
|
@property
|
497
496
|
def boolean_outcome(self) -> bool:
|
@@ -548,9 +547,7 @@ class OmenBet(BaseModel):
|
|
548
547
|
market_question=self.title,
|
549
548
|
market_id=self.fpmm.id,
|
550
549
|
market_outcome=self.fpmm.boolean_outcome,
|
551
|
-
resolved_time=
|
552
|
-
check_not_none(self.fpmm.answerFinalizedTimestamp)
|
553
|
-
),
|
550
|
+
resolved_time=check_not_none(self.fpmm.finalized_datetime),
|
554
551
|
profit=self.get_profit(),
|
555
552
|
)
|
556
553
|
|
@@ -571,11 +568,23 @@ class RealityQuestion(BaseModel):
|
|
571
568
|
id: str
|
572
569
|
user: HexAddress
|
573
570
|
historyHash: HexBytes | None
|
574
|
-
updatedTimestamp:
|
571
|
+
updatedTimestamp: int
|
575
572
|
contentHash: HexBytes
|
576
573
|
questionId: HexBytes
|
577
|
-
answerFinalizedTimestamp:
|
578
|
-
currentScheduledFinalizationTimestamp:
|
574
|
+
answerFinalizedTimestamp: int
|
575
|
+
currentScheduledFinalizationTimestamp: int
|
576
|
+
|
577
|
+
@property
|
578
|
+
def updated_datetime(self) -> DatetimeUTC:
|
579
|
+
return DatetimeUTC.to_datetime_utc(self.updatedTimestamp)
|
580
|
+
|
581
|
+
@property
|
582
|
+
def answer_finalized_datetime(self) -> DatetimeUTC:
|
583
|
+
return DatetimeUTC.to_datetime_utc(self.answerFinalizedTimestamp)
|
584
|
+
|
585
|
+
@property
|
586
|
+
def current_scheduled_finalization_datetime(self) -> DatetimeUTC:
|
587
|
+
return DatetimeUTC.to_datetime_utc(self.currentScheduledFinalizationTimestamp)
|
579
588
|
|
580
589
|
@property
|
581
590
|
def url(self) -> str:
|
@@ -584,13 +593,17 @@ class RealityQuestion(BaseModel):
|
|
584
593
|
|
585
594
|
class RealityAnswer(BaseModel):
|
586
595
|
id: str
|
587
|
-
timestamp:
|
596
|
+
timestamp: int
|
588
597
|
answer: HexBytes
|
589
598
|
lastBond: Wei
|
590
599
|
bondAggregate: Wei
|
591
600
|
question: RealityQuestion
|
592
601
|
createdBlock: int
|
593
602
|
|
603
|
+
@property
|
604
|
+
def timestamp_datetime(self) -> DatetimeUTC:
|
605
|
+
return DatetimeUTC.to_datetime_utc(self.timestamp)
|
606
|
+
|
594
607
|
|
595
608
|
class RealityResponse(BaseModel):
|
596
609
|
"""
|
@@ -598,7 +611,7 @@ class RealityResponse(BaseModel):
|
|
598
611
|
"""
|
599
612
|
|
600
613
|
id: str
|
601
|
-
timestamp:
|
614
|
+
timestamp: int
|
602
615
|
answer: HexBytes
|
603
616
|
isUnrevealed: bool
|
604
617
|
isCommitment: bool
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import sys
|
2
2
|
import typing as t
|
3
|
-
from datetime import
|
3
|
+
from datetime import timedelta
|
4
4
|
|
5
5
|
import tenacity
|
6
6
|
from web3 import Web3
|
@@ -70,6 +70,7 @@ from prediction_market_agent_tooling.tools.contract import (
|
|
70
70
|
)
|
71
71
|
from prediction_market_agent_tooling.tools.hexbytes_custom import HexBytes
|
72
72
|
from prediction_market_agent_tooling.tools.utils import (
|
73
|
+
DatetimeUTC,
|
73
74
|
calculate_sell_amount_in_collateral,
|
74
75
|
check_not_none,
|
75
76
|
)
|
@@ -97,9 +98,9 @@ class OmenAgentMarket(AgentMarket):
|
|
97
98
|
collateral_token_contract_address_checksummed: ChecksumAddress
|
98
99
|
market_maker_contract_address_checksummed: ChecksumAddress
|
99
100
|
condition: Condition
|
100
|
-
finalized_time:
|
101
|
-
created_time:
|
102
|
-
close_time:
|
101
|
+
finalized_time: DatetimeUTC | None
|
102
|
+
created_time: DatetimeUTC
|
103
|
+
close_time: DatetimeUTC
|
103
104
|
fee: float # proportion, from 0 to 1
|
104
105
|
|
105
106
|
_binary_market_p_yes_history: list[Probability] | None = None
|
@@ -363,7 +364,7 @@ class OmenAgentMarket(AgentMarket):
|
|
363
364
|
limit: int,
|
364
365
|
sort_by: SortBy,
|
365
366
|
filter_by: FilterBy = FilterBy.OPEN,
|
366
|
-
created_after: t.Optional[
|
367
|
+
created_after: t.Optional[DatetimeUTC] = None,
|
367
368
|
excluded_questions: set[str] | None = None,
|
368
369
|
) -> t.Sequence["OmenAgentMarket"]:
|
369
370
|
return [
|
@@ -387,7 +388,7 @@ class OmenAgentMarket(AgentMarket):
|
|
387
388
|
|
388
389
|
@staticmethod
|
389
390
|
def get_bets_made_since(
|
390
|
-
better_address: ChecksumAddress, start_time:
|
391
|
+
better_address: ChecksumAddress, start_time: DatetimeUTC
|
391
392
|
) -> list[Bet]:
|
392
393
|
bets = OmenSubgraphHandler().get_bets(
|
393
394
|
better_address=better_address, start_time=start_time
|
@@ -397,7 +398,9 @@ class OmenAgentMarket(AgentMarket):
|
|
397
398
|
|
398
399
|
@staticmethod
|
399
400
|
def get_resolved_bets_made_since(
|
400
|
-
better_address: ChecksumAddress,
|
401
|
+
better_address: ChecksumAddress,
|
402
|
+
start_time: DatetimeUTC,
|
403
|
+
end_time: DatetimeUTC | None,
|
401
404
|
) -> list[ResolvedBet]:
|
402
405
|
subgraph_handler = OmenSubgraphHandler()
|
403
406
|
bets = subgraph_handler.get_resolved_bets_with_valid_answer(
|
@@ -836,7 +839,7 @@ def omen_create_market_tx(
|
|
836
839
|
api_keys: APIKeys,
|
837
840
|
initial_funds: xDai,
|
838
841
|
question: str,
|
839
|
-
closing_time:
|
842
|
+
closing_time: DatetimeUTC,
|
840
843
|
category: str,
|
841
844
|
language: str,
|
842
845
|
outcomes: list[str],
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import os
|
2
2
|
import random
|
3
3
|
import typing as t
|
4
|
-
from datetime import
|
4
|
+
from datetime import timedelta
|
5
5
|
from enum import Enum
|
6
6
|
|
7
7
|
from web3 import Web3
|
@@ -40,6 +40,7 @@ from prediction_market_agent_tooling.tools.contract import (
|
|
40
40
|
init_collateral_token_contract,
|
41
41
|
to_gnosis_chain_contract,
|
42
42
|
)
|
43
|
+
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
43
44
|
from prediction_market_agent_tooling.tools.web3_utils import (
|
44
45
|
ZERO_BYTES,
|
45
46
|
byte32_to_ipfscidv0,
|
@@ -575,7 +576,7 @@ class OmenRealitioContract(ContractOnGnosisChain):
|
|
575
576
|
outcomes: list[str],
|
576
577
|
language: str,
|
577
578
|
arbitrator: Arbitrator,
|
578
|
-
opening:
|
579
|
+
opening: DatetimeUTC,
|
579
580
|
timeout: timedelta,
|
580
581
|
nonce: int | None = None,
|
581
582
|
tx_params: t.Optional[TxParams] = None,
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
|
3
1
|
from web3 import Web3
|
4
2
|
|
5
3
|
from prediction_market_agent_tooling.config import APIKeys
|
@@ -33,6 +31,7 @@ from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
|
33
31
|
from prediction_market_agent_tooling.markets.polymarket.utils import (
|
34
32
|
find_resolution_on_polymarket,
|
35
33
|
)
|
34
|
+
from prediction_market_agent_tooling.tools.utils import utcnow
|
36
35
|
from prediction_market_agent_tooling.tools.web3_utils import ZERO_BYTES, xdai_to_wei
|
37
36
|
|
38
37
|
|
@@ -131,7 +130,7 @@ def finalize_markets(
|
|
131
130
|
logger.info(
|
132
131
|
f"[{idx+1} / {len(markets_with_resolutions)}] Looking into {market.url=} {market.question_title=}"
|
133
132
|
)
|
134
|
-
closed_before_days = (
|
133
|
+
closed_before_days = (utcnow() - market.close_time).days
|
135
134
|
|
136
135
|
if resolution is None:
|
137
136
|
if closed_before_days > wait_n_days_before_invalid:
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import sys
|
2
2
|
import typing as t
|
3
|
-
from datetime import datetime
|
4
3
|
|
5
4
|
import requests
|
6
5
|
import tenacity
|
@@ -35,7 +34,11 @@ from prediction_market_agent_tooling.markets.omen.omen_contracts import (
|
|
35
34
|
sDaiContract,
|
36
35
|
)
|
37
36
|
from prediction_market_agent_tooling.tools.singleton import SingletonMeta
|
38
|
-
from prediction_market_agent_tooling.tools.utils import
|
37
|
+
from prediction_market_agent_tooling.tools.utils import (
|
38
|
+
DatetimeUTC,
|
39
|
+
to_int_timestamp,
|
40
|
+
utcnow,
|
41
|
+
)
|
39
42
|
from prediction_market_agent_tooling.tools.web3_utils import (
|
40
43
|
ZERO_BYTES,
|
41
44
|
byte32_to_ipfscidv0,
|
@@ -213,11 +216,11 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
213
216
|
creator: t.Optional[HexAddress] = None,
|
214
217
|
creator_in: t.Optional[t.Sequence[HexAddress]] = None,
|
215
218
|
outcomes: list[str] = OMEN_BINARY_MARKET_OUTCOMES,
|
216
|
-
created_after: t.Optional[
|
217
|
-
opened_before: t.Optional[
|
218
|
-
opened_after: t.Optional[
|
219
|
-
finalized_before: t.Optional[
|
220
|
-
finalized_after: t.Optional[
|
219
|
+
created_after: t.Optional[DatetimeUTC] = None,
|
220
|
+
opened_before: t.Optional[DatetimeUTC] = None,
|
221
|
+
opened_after: t.Optional[DatetimeUTC] = None,
|
222
|
+
finalized_before: t.Optional[DatetimeUTC] = None,
|
223
|
+
finalized_after: t.Optional[DatetimeUTC] = None,
|
221
224
|
finalized: bool | None = None,
|
222
225
|
resolved: bool | None = None,
|
223
226
|
liquidity_bigger_than: Wei | None = None,
|
@@ -344,7 +347,7 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
344
347
|
filter_by: FilterBy,
|
345
348
|
sort_by: SortBy,
|
346
349
|
# Additional filters, these can not be modified by the enums above.
|
347
|
-
created_after:
|
350
|
+
created_after: DatetimeUTC | None = None,
|
348
351
|
excluded_questions: set[str] | None = None, # question titles
|
349
352
|
collateral_token_address_in: (
|
350
353
|
tuple[ChecksumAddress, ...] | None
|
@@ -357,7 +360,7 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
357
360
|
# These values need to be set according to the filter_by value, so they can not be passed as arguments.
|
358
361
|
finalized: bool | None = None
|
359
362
|
resolved: bool | None = None
|
360
|
-
opened_after:
|
363
|
+
opened_after: DatetimeUTC | None = None
|
361
364
|
liquidity_bigger_than: Wei | None = None
|
362
365
|
|
363
366
|
if filter_by == FilterBy.RESOLVED:
|
@@ -393,11 +396,11 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
393
396
|
def get_omen_binary_markets(
|
394
397
|
self,
|
395
398
|
limit: t.Optional[int],
|
396
|
-
created_after: t.Optional[
|
397
|
-
opened_before: t.Optional[
|
398
|
-
opened_after: t.Optional[
|
399
|
-
finalized_before: t.Optional[
|
400
|
-
finalized_after: t.Optional[
|
399
|
+
created_after: t.Optional[DatetimeUTC] = None,
|
400
|
+
opened_before: t.Optional[DatetimeUTC] = None,
|
401
|
+
opened_after: t.Optional[DatetimeUTC] = None,
|
402
|
+
finalized_before: t.Optional[DatetimeUTC] = None,
|
403
|
+
finalized_after: t.Optional[DatetimeUTC] = None,
|
401
404
|
finalized: bool | None = None,
|
402
405
|
resolved: bool | None = None,
|
403
406
|
creator: t.Optional[HexAddress] = None,
|
@@ -554,12 +557,12 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
554
557
|
def get_trades(
|
555
558
|
self,
|
556
559
|
better_address: ChecksumAddress | None = None,
|
557
|
-
start_time:
|
558
|
-
end_time: t.Optional[
|
560
|
+
start_time: DatetimeUTC | None = None,
|
561
|
+
end_time: t.Optional[DatetimeUTC] = None,
|
559
562
|
market_id: t.Optional[ChecksumAddress] = None,
|
560
563
|
filter_by_answer_finalized_not_null: bool = False,
|
561
564
|
type_: t.Literal["Buy", "Sell"] | None = None,
|
562
|
-
market_opening_after:
|
565
|
+
market_opening_after: DatetimeUTC | None = None,
|
563
566
|
collateral_amount_more_than: Wei | None = None,
|
564
567
|
) -> list[OmenBet]:
|
565
568
|
if not end_time:
|
@@ -597,11 +600,11 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
597
600
|
def get_bets(
|
598
601
|
self,
|
599
602
|
better_address: ChecksumAddress | None = None,
|
600
|
-
start_time:
|
601
|
-
end_time: t.Optional[
|
603
|
+
start_time: DatetimeUTC | None = None,
|
604
|
+
end_time: t.Optional[DatetimeUTC] = None,
|
602
605
|
market_id: t.Optional[ChecksumAddress] = None,
|
603
606
|
filter_by_answer_finalized_not_null: bool = False,
|
604
|
-
market_opening_after:
|
607
|
+
market_opening_after: DatetimeUTC | None = None,
|
605
608
|
collateral_amount_more_than: Wei | None = None,
|
606
609
|
) -> list[OmenBet]:
|
607
610
|
return self.get_trades(
|
@@ -618,8 +621,8 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
618
621
|
def get_resolved_bets(
|
619
622
|
self,
|
620
623
|
better_address: ChecksumAddress,
|
621
|
-
start_time:
|
622
|
-
end_time: t.Optional[
|
624
|
+
start_time: DatetimeUTC,
|
625
|
+
end_time: t.Optional[DatetimeUTC] = None,
|
623
626
|
market_id: t.Optional[ChecksumAddress] = None,
|
624
627
|
) -> list[OmenBet]:
|
625
628
|
omen_bets = self.get_bets(
|
@@ -634,8 +637,8 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
634
637
|
def get_resolved_bets_with_valid_answer(
|
635
638
|
self,
|
636
639
|
better_address: ChecksumAddress,
|
637
|
-
start_time:
|
638
|
-
end_time: t.Optional[
|
640
|
+
start_time: DatetimeUTC,
|
641
|
+
end_time: t.Optional[DatetimeUTC] = None,
|
639
642
|
market_id: t.Optional[ChecksumAddress] = None,
|
640
643
|
) -> list[OmenBet]:
|
641
644
|
bets = self.get_resolved_bets(
|
@@ -650,9 +653,9 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
650
653
|
def get_reality_question_filters(
|
651
654
|
user: HexAddress | None = None,
|
652
655
|
claimed: bool | None = None,
|
653
|
-
current_answer_before:
|
654
|
-
finalized_before:
|
655
|
-
finalized_after:
|
656
|
+
current_answer_before: DatetimeUTC | None = None,
|
657
|
+
finalized_before: DatetimeUTC | None = None,
|
658
|
+
finalized_after: DatetimeUTC | None = None,
|
656
659
|
id_in: list[str] | None = None,
|
657
660
|
question_id: HexBytes | None = None,
|
658
661
|
question_id_in: list[HexBytes] | None = None,
|
@@ -699,9 +702,9 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
699
702
|
limit: int | None,
|
700
703
|
user: HexAddress | None = None,
|
701
704
|
claimed: bool | None = None,
|
702
|
-
current_answer_before:
|
703
|
-
finalized_before:
|
704
|
-
finalized_after:
|
705
|
+
current_answer_before: DatetimeUTC | None = None,
|
706
|
+
finalized_before: DatetimeUTC | None = None,
|
707
|
+
finalized_after: DatetimeUTC | None = None,
|
705
708
|
id_in: list[str] | None = None,
|
706
709
|
question_id_in: list[HexBytes] | None = None,
|
707
710
|
) -> list[RealityQuestion]:
|
@@ -744,9 +747,9 @@ class OmenSubgraphHandler(metaclass=SingletonMeta):
|
|
744
747
|
user: HexAddress | None = None,
|
745
748
|
question_id: HexBytes | None = None,
|
746
749
|
question_claimed: bool | None = None,
|
747
|
-
question_finalized_before:
|
748
|
-
question_finalized_after:
|
749
|
-
question_current_answer_before:
|
750
|
+
question_finalized_before: DatetimeUTC | None = None,
|
751
|
+
question_finalized_after: DatetimeUTC | None = None,
|
752
|
+
question_current_answer_before: DatetimeUTC | None = None,
|
750
753
|
question_id_in: list[HexBytes] | None = None,
|
751
754
|
) -> list[RealityResponse]:
|
752
755
|
where_stms: dict[str, t.Any] = {}
|
@@ -1,5 +1,3 @@
|
|
1
|
-
from datetime import datetime
|
2
|
-
|
3
1
|
from pydantic import BaseModel
|
4
2
|
|
5
3
|
from prediction_market_agent_tooling.gtypes import USDC, Probability, usdc_type
|
@@ -10,13 +8,14 @@ from prediction_market_agent_tooling.markets.polymarket.data_models_web import (
|
|
10
8
|
PolymarketFullMarket,
|
11
9
|
construct_polymarket_url,
|
12
10
|
)
|
11
|
+
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
13
12
|
|
14
13
|
|
15
14
|
class PolymarketRewards(BaseModel):
|
16
15
|
min_size: int
|
17
16
|
max_spread: float | None
|
18
|
-
event_start_date:
|
19
|
-
event_end_date:
|
17
|
+
event_start_date: DatetimeUTC | None = None
|
18
|
+
event_end_date: DatetimeUTC | None = None
|
20
19
|
in_game_multiplier: int | None = None
|
21
20
|
reward_epoch: int | None = None
|
22
21
|
|
@@ -39,8 +38,8 @@ class PolymarketMarket(BaseModel):
|
|
39
38
|
question: str
|
40
39
|
description: str
|
41
40
|
market_slug: str
|
42
|
-
end_date_iso:
|
43
|
-
game_start_time:
|
41
|
+
end_date_iso: DatetimeUTC | None
|
42
|
+
game_start_time: DatetimeUTC | None
|
44
43
|
seconds_delay: int
|
45
44
|
fpmm: str
|
46
45
|
maker_base_fee: int
|
@@ -7,7 +7,6 @@ These models are based on what Polymarket's website returns in the response, and
|
|
7
7
|
|
8
8
|
import json
|
9
9
|
import typing as t
|
10
|
-
from datetime import datetime
|
11
10
|
|
12
11
|
import requests
|
13
12
|
from pydantic import BaseModel, field_validator
|
@@ -15,6 +14,7 @@ from pydantic import BaseModel, field_validator
|
|
15
14
|
from prediction_market_agent_tooling.gtypes import USDC, HexAddress
|
16
15
|
from prediction_market_agent_tooling.loggers import logger
|
17
16
|
from prediction_market_agent_tooling.markets.data_models import Resolution
|
17
|
+
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
18
18
|
|
19
19
|
POLYMARKET_BASE_URL = "https://polymarket.com"
|
20
20
|
POLYMARKET_TRUE_OUTCOME = "Yes"
|
@@ -38,7 +38,7 @@ class Event(BaseModel):
|
|
38
38
|
|
39
39
|
|
40
40
|
class Event1(BaseModel):
|
41
|
-
startDate:
|
41
|
+
startDate: DatetimeUTC | None = None
|
42
42
|
slug: str
|
43
43
|
|
44
44
|
|
@@ -60,7 +60,7 @@ class Market1(BaseModel):
|
|
60
60
|
class ResolutionData(BaseModel):
|
61
61
|
id: str
|
62
62
|
author: str
|
63
|
-
lastUpdateTimestamp:
|
63
|
+
lastUpdateTimestamp: int
|
64
64
|
status: str
|
65
65
|
wasDisputed: bool
|
66
66
|
price: str
|
@@ -79,13 +79,13 @@ class Market(BaseModel):
|
|
79
79
|
slug: str
|
80
80
|
twitterCardImage: t.Any | None = None
|
81
81
|
resolutionSource: str | None = None
|
82
|
-
endDate:
|
82
|
+
endDate: DatetimeUTC
|
83
83
|
category: t.Any | None = None
|
84
84
|
ammType: t.Any | None = None
|
85
85
|
description: str
|
86
86
|
liquidity: str | None = None
|
87
|
-
startDate:
|
88
|
-
createdAt:
|
87
|
+
startDate: DatetimeUTC | None = None
|
88
|
+
createdAt: DatetimeUTC
|
89
89
|
xAxisValue: t.Any | None = None
|
90
90
|
yAxisValue: t.Any | None = None
|
91
91
|
denominationToken: t.Any | None = None
|
@@ -106,7 +106,7 @@ class Market(BaseModel):
|
|
106
106
|
upperBoundDate: t.Any | None = None
|
107
107
|
closed: bool
|
108
108
|
marketMakerAddress: HexAddress
|
109
|
-
closedTime:
|
109
|
+
closedTime: DatetimeUTC | None = None
|
110
110
|
wideFormat: bool | None = None
|
111
111
|
new: bool | None = None
|
112
112
|
sentDiscord: t.Any | None = None
|
@@ -129,9 +129,9 @@ class Market(BaseModel):
|
|
129
129
|
curationOrder: t.Any | None = None
|
130
130
|
volumeNum: USDC | None = None
|
131
131
|
liquidityNum: float | None = None
|
132
|
-
endDateIso:
|
133
|
-
startDateIso:
|
134
|
-
umaEndDateIso:
|
132
|
+
endDateIso: DatetimeUTC | None = None
|
133
|
+
startDateIso: DatetimeUTC | None = None
|
134
|
+
umaEndDateIso: DatetimeUTC | None = None
|
135
135
|
commentsEnabled: bool | None = None
|
136
136
|
disqusThread: t.Any | None = None
|
137
137
|
gameStartTime: t.Any | None = None
|
@@ -236,8 +236,8 @@ class PolymarketFullMarket(BaseModel):
|
|
236
236
|
description: str
|
237
237
|
commentCount: int | None = None
|
238
238
|
resolutionSource: str | None = None
|
239
|
-
startDate:
|
240
|
-
endDate:
|
239
|
+
startDate: DatetimeUTC | None = None
|
240
|
+
endDate: DatetimeUTC
|
241
241
|
image: str | None = None
|
242
242
|
icon: str | None = None
|
243
243
|
featuredImage: str | None = None
|
@@ -253,10 +253,10 @@ class PolymarketFullMarket(BaseModel):
|
|
253
253
|
competitive: float | None = None
|
254
254
|
openInterest: int | None = None
|
255
255
|
sortBy: str | None = None
|
256
|
-
createdAt:
|
256
|
+
createdAt: DatetimeUTC
|
257
257
|
commentsEnabled: bool | None = None
|
258
258
|
disqusThread: t.Any | None = None
|
259
|
-
updatedAt:
|
259
|
+
updatedAt: DatetimeUTC
|
260
260
|
enableOrderBook: bool | None = None
|
261
261
|
liquidityAmm: float | None = None
|
262
262
|
liquidityClob: float | None = None
|
@@ -1,5 +1,4 @@
|
|
1
1
|
import typing as t
|
2
|
-
from datetime import datetime
|
3
2
|
|
4
3
|
from prediction_market_agent_tooling.markets.agent_market import (
|
5
4
|
AgentMarket,
|
@@ -16,6 +15,7 @@ from prediction_market_agent_tooling.markets.polymarket.data_models import (
|
|
16
15
|
from prediction_market_agent_tooling.markets.polymarket.data_models_web import (
|
17
16
|
POLYMARKET_BASE_URL,
|
18
17
|
)
|
18
|
+
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
19
19
|
|
20
20
|
|
21
21
|
class PolymarketAgentMarket(AgentMarket):
|
@@ -54,7 +54,7 @@ class PolymarketAgentMarket(AgentMarket):
|
|
54
54
|
limit: int,
|
55
55
|
sort_by: SortBy = SortBy.NONE,
|
56
56
|
filter_by: FilterBy = FilterBy.OPEN,
|
57
|
-
created_after: t.Optional[
|
57
|
+
created_after: t.Optional[DatetimeUTC] = None,
|
58
58
|
excluded_questions: set[str] | None = None,
|
59
59
|
) -> t.Sequence["PolymarketAgentMarket"]:
|
60
60
|
if sort_by != SortBy.NONE:
|
@@ -15,7 +15,7 @@ from prediction_market_agent_tooling.monitor.monitor import (
|
|
15
15
|
DeployedAgent,
|
16
16
|
KubernetesCronJob,
|
17
17
|
)
|
18
|
-
from prediction_market_agent_tooling.tools.utils import
|
18
|
+
from prediction_market_agent_tooling.tools.utils import DatetimeUTC
|
19
19
|
|
20
20
|
|
21
21
|
class DeployedManifoldAgent(DeployedAgent):
|
@@ -57,7 +57,7 @@ class DeployedManifoldAgent(DeployedAgent):
|
|
57
57
|
@staticmethod
|
58
58
|
def from_api_keys(
|
59
59
|
name: str,
|
60
|
-
start_time:
|
60
|
+
start_time: DatetimeUTC,
|
61
61
|
api_keys: APIKeys,
|
62
62
|
) -> "DeployedManifoldAgent":
|
63
63
|
return DeployedManifoldAgent(
|
@@ -4,7 +4,7 @@ from google.cloud.functions_v2.types.functions import Function
|
|
4
4
|
|
5
5
|
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
|
-
from prediction_market_agent_tooling.gtypes import
|
7
|
+
from prediction_market_agent_tooling.gtypes import DatetimeUTC
|
8
8
|
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
9
9
|
from prediction_market_agent_tooling.markets.markets import MarketType
|
10
10
|
from prediction_market_agent_tooling.monitor.monitor import DeployedAgent
|
@@ -23,7 +23,7 @@ class DeployedMetaculusAgent(DeployedAgent):
|
|
23
23
|
@staticmethod
|
24
24
|
def from_api_keys(
|
25
25
|
name: str,
|
26
|
-
start_time:
|
26
|
+
start_time: DatetimeUTC,
|
27
27
|
api_keys: APIKeys,
|
28
28
|
) -> "DeployedMetaculusAgent":
|
29
29
|
return DeployedMetaculusAgent(
|
@@ -4,7 +4,7 @@ from google.cloud.functions_v2.types.functions import Function
|
|
4
4
|
|
5
5
|
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
|
-
from prediction_market_agent_tooling.gtypes import ChecksumAddress,
|
7
|
+
from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeUTC
|
8
8
|
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
9
9
|
from prediction_market_agent_tooling.markets.markets import MarketType
|
10
10
|
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import (
|
@@ -57,7 +57,7 @@ class DeployedOmenAgent(DeployedAgent):
|
|
57
57
|
@staticmethod
|
58
58
|
def from_api_keys(
|
59
59
|
name: str,
|
60
|
-
start_time:
|
60
|
+
start_time: DatetimeUTC,
|
61
61
|
api_keys: APIKeys,
|
62
62
|
) -> "DeployedOmenAgent":
|
63
63
|
return DeployedOmenAgent(
|
@@ -4,7 +4,7 @@ from google.cloud.functions_v2.types.functions import Function
|
|
4
4
|
|
5
5
|
from prediction_market_agent_tooling.config import APIKeys
|
6
6
|
from prediction_market_agent_tooling.deploy.constants import MARKET_TYPE_KEY
|
7
|
-
from prediction_market_agent_tooling.gtypes import ChecksumAddress,
|
7
|
+
from prediction_market_agent_tooling.gtypes import ChecksumAddress, DatetimeUTC
|
8
8
|
from prediction_market_agent_tooling.markets.data_models import ResolvedBet
|
9
9
|
from prediction_market_agent_tooling.markets.markets import MarketType
|
10
10
|
from prediction_market_agent_tooling.monitor.monitor import DeployedAgent
|
@@ -25,7 +25,7 @@ class DeployedPolymarketAgent(DeployedAgent):
|
|
25
25
|
@staticmethod
|
26
26
|
def from_api_keys(
|
27
27
|
name: str,
|
28
|
-
start_time:
|
28
|
+
start_time: DatetimeUTC,
|
29
29
|
api_keys: APIKeys,
|
30
30
|
) -> "DeployedPolymarketAgent":
|
31
31
|
return DeployedPolymarketAgent(
|