Deploy Module
prediction_market_agent_tooling.deploy
agent
MAX_AVAILABLE_MARKETS
module-attribute
MAX_AVAILABLE_MARKETS = 1000
AnsweredEnum
Bases: str, Enum
ANSWERED
class-attribute
instance-attribute
ANSWERED = 'answered'
NOT_ANSWERED
class-attribute
instance-attribute
NOT_ANSWERED = 'not_answered'
AgentTagEnum
Bases: str, Enum
PREDICTOR
class-attribute
instance-attribute
PREDICTOR = 'predictor'
TRADER
class-attribute
instance-attribute
TRADER = 'trader'
DeployableAgent
DeployableAgent(
enable_langfuse: bool = APIKeys().default_enable_langfuse,
)
Subclass this class to create agent with standardized interface.
Source code in prediction_market_agent_tooling/deploy/agent.py
89 90 91 92 93 94 95 96 97 | |
start_time
instance-attribute
start_time = utcnow()
enable_langfuse
instance-attribute
enable_langfuse = enable_langfuse
api_keys
instance-attribute
api_keys = APIKeys()
session_id
cached
property
session_id: str
initialize_langfuse
initialize_langfuse() -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
99 100 | |
langfuse_update_current_trace
langfuse_update_current_trace(
name: str | None = None,
input: Any | None = None,
output: Any | None = None,
user_id: str | None = None,
session_id: str | None = None,
version: str | None = None,
release: str | None = None,
metadata: Any | None = None,
tags: list[str] | None = None,
public: bool | None = None,
) -> None
Provide some useful default arguments when updating the current trace in our agents.
Source code in prediction_market_agent_tooling/deploy/agent.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
load
load() -> None
Implement this method to load arbitrary instances needed across the whole run of the agent.
Do not customize init method.
Source code in prediction_market_agent_tooling/deploy/agent.py
149 150 151 152 153 154 | |
deploy_local
deploy_local(
market_type: MarketType,
sleep_time: float,
run_time: float | None,
) -> None
Run the agent in the forever cycle every sleep_time seconds, until the run_time is met.
Source code in prediction_market_agent_tooling/deploy/agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
run
run(market_type: MarketType) -> None
Run single iteration of the agent.
Source code in prediction_market_agent_tooling/deploy/agent.py
170 171 172 173 174 | |
get_gcloud_fname
get_gcloud_fname(market_type: MarketType) -> str
Source code in prediction_market_agent_tooling/deploy/agent.py
176 177 | |
DeployablePredictionAgent
DeployablePredictionAgent(
enable_langfuse: bool = APIKeys().default_enable_langfuse,
store_predictions: bool = True,
)
Bases: DeployableAgent
Subclass this class to create your own prediction market agent.
The agent will process markets and make predictions.
Source code in prediction_market_agent_tooling/deploy/agent.py
208 209 210 211 212 213 214 | |
AGENT_TAG
class-attribute
instance-attribute
AGENT_TAG: AgentTagEnum = PREDICTOR
bet_on_n_markets_per_run
class-attribute
instance-attribute
bet_on_n_markets_per_run: int = 1
n_markets_to_fetch
class-attribute
instance-attribute
n_markets_to_fetch: int = MAX_AVAILABLE_MARKETS
trade_on_markets_created_after
class-attribute
instance-attribute
trade_on_markets_created_after: DatetimeUTC | None = None
get_markets_sort_by
class-attribute
instance-attribute
get_markets_sort_by: SortBy = CLOSING_SOONEST
get_markets_filter_by
class-attribute
instance-attribute
get_markets_filter_by: FilterBy = OPEN
allow_invalid_questions
class-attribute
instance-attribute
allow_invalid_questions: bool = False
same_market_trade_interval
class-attribute
instance-attribute
same_market_trade_interval: TradeInterval = FixedInterval(
timedelta(hours=24)
)
min_balance_to_keep_in_native_currency
class-attribute
instance-attribute
min_balance_to_keep_in_native_currency: xDai | None = (
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
)
supported_markets
class-attribute
instance-attribute
supported_markets: Sequence[MarketType] = [METACULUS]
store_predictions
instance-attribute
store_predictions = store_predictions
agent_name
property
agent_name: str
fetch_categorical_markets
property
fetch_categorical_markets: bool
start_time
instance-attribute
start_time = utcnow()
enable_langfuse
instance-attribute
enable_langfuse = enable_langfuse
api_keys
instance-attribute
api_keys = APIKeys()
session_id
cached
property
session_id: str
initialize_langfuse
initialize_langfuse() -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
216 217 218 219 220 221 222 | |
update_langfuse_trace_by_market
update_langfuse_trace_by_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
update_langfuse_trace_by_processed_market
update_langfuse_trace_by_processed_market(
market_type: MarketType,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
check_min_required_balance_to_operate
check_min_required_balance_to_operate(
market_type: MarketType,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
256 257 258 259 260 261 262 | |
verify_market
verify_market(
market_type: MarketType, market: AgentMarket
) -> bool
Subclasses can implement their own logic instead of this one, or on top of this one. By default, it allows only markets where user didn't bet recently and it's a reasonable question.
Source code in prediction_market_agent_tooling/deploy/agent.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
answer_categorical_market
answer_categorical_market(
market: AgentMarket,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
297 298 299 300 | |
answer_binary_market
answer_binary_market(
market: AgentMarket,
) -> ProbabilisticAnswer | None
Answer the binary market.
If this method is not overridden by the subclass, it will fall back to using answer_categorical_market(). Therefore, subclasses only need to implement answer_categorical_market() if they want to handle both types of markets.
Source code in prediction_market_agent_tooling/deploy/agent.py
302 303 304 305 306 307 308 309 310 311 312 | |
get_markets
get_markets(
market_type: MarketType,
) -> t.Sequence[AgentMarket]
Override this method to customize what markets will fetch for processing.
Source code in prediction_market_agent_tooling/deploy/agent.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
before_process_market
before_process_market(
market_type: MarketType, market: AgentMarket
) -> None
Executed before processing of each market.
Source code in prediction_market_agent_tooling/deploy/agent.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
build_answer
build_answer(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
process_market
process_market(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> ProcessedMarket | None
Source code in prediction_market_agent_tooling/deploy/agent.py
388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 | |
after_process_market
after_process_market(
market_type: MarketType,
market: AgentMarket,
processed_market: ProcessedMarket | None,
) -> None
Executed after processing of each market.
Source code in prediction_market_agent_tooling/deploy/agent.py
413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 | |
before_process_markets
before_process_markets(market_type: MarketType) -> None
Executed before market processing loop starts.
Source code in prediction_market_agent_tooling/deploy/agent.py
432 433 434 435 436 437 438 | |
process_markets
process_markets(market_type: MarketType) -> None
Processes bets placed by agents on a given market.
Source code in prediction_market_agent_tooling/deploy/agent.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
after_process_markets
after_process_markets(market_type: MarketType) -> None
Executed after market processing loop ends.
Source code in prediction_market_agent_tooling/deploy/agent.py
470 471 472 473 | |
run
run(market_type: MarketType) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
475 476 477 478 479 480 481 482 | |
langfuse_update_current_trace
langfuse_update_current_trace(
name: str | None = None,
input: Any | None = None,
output: Any | None = None,
user_id: str | None = None,
session_id: str | None = None,
version: str | None = None,
release: str | None = None,
metadata: Any | None = None,
tags: list[str] | None = None,
public: bool | None = None,
) -> None
Provide some useful default arguments when updating the current trace in our agents.
Source code in prediction_market_agent_tooling/deploy/agent.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
load
load() -> None
Implement this method to load arbitrary instances needed across the whole run of the agent.
Do not customize init method.
Source code in prediction_market_agent_tooling/deploy/agent.py
149 150 151 152 153 154 | |
deploy_local
deploy_local(
market_type: MarketType,
sleep_time: float,
run_time: float | None,
) -> None
Run the agent in the forever cycle every sleep_time seconds, until the run_time is met.
Source code in prediction_market_agent_tooling/deploy/agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
get_gcloud_fname
get_gcloud_fname(market_type: MarketType) -> str
Source code in prediction_market_agent_tooling/deploy/agent.py
176 177 | |
DeployableTraderAgent
DeployableTraderAgent(
enable_langfuse: bool = APIKeys().default_enable_langfuse,
store_predictions: bool = True,
store_trades: bool = True,
place_trades: bool = True,
)
Bases: DeployablePredictionAgent
Subclass this class to create your own prediction market trading agent.
The agent will process markets, make predictions and place trades (bets) based off these predictions.
Source code in prediction_market_agent_tooling/deploy/agent.py
502 503 504 505 506 507 508 509 510 511 512 513 | |
AGENT_TAG
class-attribute
instance-attribute
AGENT_TAG: AgentTagEnum = TRADER
supported_markets
class-attribute
instance-attribute
supported_markets: Sequence[MarketType] = [
OMEN,
MANIFOLD,
POLYMARKET,
SEER,
]
store_trades
instance-attribute
store_trades = store_trades
place_trades
instance-attribute
place_trades = place_trades
start_time
instance-attribute
start_time = utcnow()
enable_langfuse
instance-attribute
enable_langfuse = enable_langfuse
api_keys
instance-attribute
api_keys = APIKeys()
session_id
cached
property
session_id: str
bet_on_n_markets_per_run
class-attribute
instance-attribute
bet_on_n_markets_per_run: int = 1
n_markets_to_fetch
class-attribute
instance-attribute
n_markets_to_fetch: int = MAX_AVAILABLE_MARKETS
trade_on_markets_created_after
class-attribute
instance-attribute
trade_on_markets_created_after: DatetimeUTC | None = None
get_markets_sort_by
class-attribute
instance-attribute
get_markets_sort_by: SortBy = CLOSING_SOONEST
get_markets_filter_by
class-attribute
instance-attribute
get_markets_filter_by: FilterBy = OPEN
allow_invalid_questions
class-attribute
instance-attribute
allow_invalid_questions: bool = False
same_market_trade_interval
class-attribute
instance-attribute
same_market_trade_interval: TradeInterval = FixedInterval(
timedelta(hours=24)
)
min_balance_to_keep_in_native_currency
class-attribute
instance-attribute
min_balance_to_keep_in_native_currency: xDai | None = (
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
)
store_predictions
instance-attribute
store_predictions = store_predictions
agent_name
property
agent_name: str
fetch_categorical_markets
property
fetch_categorical_markets: bool
initialize_langfuse
initialize_langfuse() -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
515 516 517 518 | |
check_min_required_balance_to_trade
check_min_required_balance_to_trade(
market: AgentMarket,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
520 521 522 523 524 525 526 527 528 529 530 531 | |
get_total_amount_to_bet
staticmethod
get_total_amount_to_bet(market: AgentMarket) -> USD
Source code in prediction_market_agent_tooling/deploy/agent.py
533 534 535 536 537 538 539 540 541 | |
get_betting_strategy
get_betting_strategy(
market: AgentMarket,
) -> BettingStrategy
Override this method to customize betting strategy of your agent.
Given the market and prediction, agent uses this method to calculate optimal outcome and bet size.
Source code in prediction_market_agent_tooling/deploy/agent.py
543 544 545 546 547 548 549 550 | |
build_trades
build_trades(
market: AgentMarket,
answer: CategoricalProbabilisticAnswer,
existing_position: ExistingPosition | None,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/agent.py
552 553 554 555 556 557 558 559 560 | |
before_process_market
before_process_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
562 563 564 565 566 | |
process_market
process_market(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> ProcessedTradedMarket | None
Source code in prediction_market_agent_tooling/deploy/agent.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
after_process_market
after_process_market(
market_type: MarketType,
market: AgentMarket,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
langfuse_update_current_trace
langfuse_update_current_trace(
name: str | None = None,
input: Any | None = None,
output: Any | None = None,
user_id: str | None = None,
session_id: str | None = None,
version: str | None = None,
release: str | None = None,
metadata: Any | None = None,
tags: list[str] | None = None,
public: bool | None = None,
) -> None
Provide some useful default arguments when updating the current trace in our agents.
Source code in prediction_market_agent_tooling/deploy/agent.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
load
load() -> None
Implement this method to load arbitrary instances needed across the whole run of the agent.
Do not customize init method.
Source code in prediction_market_agent_tooling/deploy/agent.py
149 150 151 152 153 154 | |
deploy_local
deploy_local(
market_type: MarketType,
sleep_time: float,
run_time: float | None,
) -> None
Run the agent in the forever cycle every sleep_time seconds, until the run_time is met.
Source code in prediction_market_agent_tooling/deploy/agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
run
run(market_type: MarketType) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
475 476 477 478 479 480 481 482 | |
get_gcloud_fname
get_gcloud_fname(market_type: MarketType) -> str
Source code in prediction_market_agent_tooling/deploy/agent.py
176 177 | |
update_langfuse_trace_by_market
update_langfuse_trace_by_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
update_langfuse_trace_by_processed_market
update_langfuse_trace_by_processed_market(
market_type: MarketType,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
check_min_required_balance_to_operate
check_min_required_balance_to_operate(
market_type: MarketType,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
256 257 258 259 260 261 262 | |
verify_market
verify_market(
market_type: MarketType, market: AgentMarket
) -> bool
Subclasses can implement their own logic instead of this one, or on top of this one. By default, it allows only markets where user didn't bet recently and it's a reasonable question.
Source code in prediction_market_agent_tooling/deploy/agent.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
answer_categorical_market
answer_categorical_market(
market: AgentMarket,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
297 298 299 300 | |
answer_binary_market
answer_binary_market(
market: AgentMarket,
) -> ProbabilisticAnswer | None
Answer the binary market.
If this method is not overridden by the subclass, it will fall back to using answer_categorical_market(). Therefore, subclasses only need to implement answer_categorical_market() if they want to handle both types of markets.
Source code in prediction_market_agent_tooling/deploy/agent.py
302 303 304 305 306 307 308 309 310 311 312 | |
get_markets
get_markets(
market_type: MarketType,
) -> t.Sequence[AgentMarket]
Override this method to customize what markets will fetch for processing.
Source code in prediction_market_agent_tooling/deploy/agent.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
build_answer
build_answer(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
before_process_markets
before_process_markets(market_type: MarketType) -> None
Executed before market processing loop starts.
Source code in prediction_market_agent_tooling/deploy/agent.py
432 433 434 435 436 437 438 | |
process_markets
process_markets(market_type: MarketType) -> None
Processes bets placed by agents on a given market.
Source code in prediction_market_agent_tooling/deploy/agent.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
after_process_markets
after_process_markets(market_type: MarketType) -> None
Executed after market processing loop ends.
Source code in prediction_market_agent_tooling/deploy/agent.py
470 471 472 473 | |
initialize_langfuse
initialize_langfuse(enable_langfuse: bool) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
59 60 61 62 63 64 65 66 67 68 69 70 71 | |
agent_example
DeployableCoinFlipAgent
DeployableCoinFlipAgent(
enable_langfuse: bool = APIKeys().default_enable_langfuse,
store_predictions: bool = True,
store_trades: bool = True,
place_trades: bool = True,
)
Bases: DeployableTraderAgent
Source code in prediction_market_agent_tooling/deploy/agent.py
502 503 504 505 506 507 508 509 510 511 512 513 | |
get_markets_sort_by
class-attribute
instance-attribute
get_markets_sort_by = HIGHEST_LIQUIDITY
start_time
instance-attribute
start_time = utcnow()
enable_langfuse
instance-attribute
enable_langfuse = enable_langfuse
api_keys
instance-attribute
api_keys = APIKeys()
session_id
cached
property
session_id: str
AGENT_TAG
class-attribute
instance-attribute
AGENT_TAG: AgentTagEnum = TRADER
bet_on_n_markets_per_run
class-attribute
instance-attribute
bet_on_n_markets_per_run: int = 1
n_markets_to_fetch
class-attribute
instance-attribute
n_markets_to_fetch: int = MAX_AVAILABLE_MARKETS
trade_on_markets_created_after
class-attribute
instance-attribute
trade_on_markets_created_after: DatetimeUTC | None = None
get_markets_filter_by
class-attribute
instance-attribute
get_markets_filter_by: FilterBy = OPEN
allow_invalid_questions
class-attribute
instance-attribute
allow_invalid_questions: bool = False
same_market_trade_interval
class-attribute
instance-attribute
same_market_trade_interval: TradeInterval = FixedInterval(
timedelta(hours=24)
)
min_balance_to_keep_in_native_currency
class-attribute
instance-attribute
min_balance_to_keep_in_native_currency: xDai | None = (
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
)
supported_markets
class-attribute
instance-attribute
supported_markets: Sequence[MarketType] = [
OMEN,
MANIFOLD,
POLYMARKET,
SEER,
]
store_predictions
instance-attribute
store_predictions = store_predictions
agent_name
property
agent_name: str
fetch_categorical_markets
property
fetch_categorical_markets: bool
store_trades
instance-attribute
store_trades = store_trades
place_trades
instance-attribute
place_trades = place_trades
verify_market
verify_market(
market_type: MarketType, market: AgentMarket
) -> bool
Source code in prediction_market_agent_tooling/deploy/agent_example.py
15 16 | |
answer_categorical_market
answer_categorical_market(
market: AgentMarket,
) -> CategoricalProbabilisticAnswer
Source code in prediction_market_agent_tooling/deploy/agent_example.py
18 19 20 21 22 23 24 25 26 27 28 29 30 | |
initialize_langfuse
initialize_langfuse() -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
515 516 517 518 | |
langfuse_update_current_trace
langfuse_update_current_trace(
name: str | None = None,
input: Any | None = None,
output: Any | None = None,
user_id: str | None = None,
session_id: str | None = None,
version: str | None = None,
release: str | None = None,
metadata: Any | None = None,
tags: list[str] | None = None,
public: bool | None = None,
) -> None
Provide some useful default arguments when updating the current trace in our agents.
Source code in prediction_market_agent_tooling/deploy/agent.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
load
load() -> None
Implement this method to load arbitrary instances needed across the whole run of the agent.
Do not customize init method.
Source code in prediction_market_agent_tooling/deploy/agent.py
149 150 151 152 153 154 | |
deploy_local
deploy_local(
market_type: MarketType,
sleep_time: float,
run_time: float | None,
) -> None
Run the agent in the forever cycle every sleep_time seconds, until the run_time is met.
Source code in prediction_market_agent_tooling/deploy/agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
run
run(market_type: MarketType) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
475 476 477 478 479 480 481 482 | |
get_gcloud_fname
get_gcloud_fname(market_type: MarketType) -> str
Source code in prediction_market_agent_tooling/deploy/agent.py
176 177 | |
update_langfuse_trace_by_market
update_langfuse_trace_by_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
update_langfuse_trace_by_processed_market
update_langfuse_trace_by_processed_market(
market_type: MarketType,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
check_min_required_balance_to_operate
check_min_required_balance_to_operate(
market_type: MarketType,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
256 257 258 259 260 261 262 | |
answer_binary_market
answer_binary_market(
market: AgentMarket,
) -> ProbabilisticAnswer | None
Answer the binary market.
If this method is not overridden by the subclass, it will fall back to using answer_categorical_market(). Therefore, subclasses only need to implement answer_categorical_market() if they want to handle both types of markets.
Source code in prediction_market_agent_tooling/deploy/agent.py
302 303 304 305 306 307 308 309 310 311 312 | |
get_markets
get_markets(
market_type: MarketType,
) -> t.Sequence[AgentMarket]
Override this method to customize what markets will fetch for processing.
Source code in prediction_market_agent_tooling/deploy/agent.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
before_process_market
before_process_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
562 563 564 565 566 | |
build_answer
build_answer(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
process_market
process_market(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> ProcessedTradedMarket | None
Source code in prediction_market_agent_tooling/deploy/agent.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
after_process_market
after_process_market(
market_type: MarketType,
market: AgentMarket,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
before_process_markets
before_process_markets(market_type: MarketType) -> None
Executed before market processing loop starts.
Source code in prediction_market_agent_tooling/deploy/agent.py
432 433 434 435 436 437 438 | |
process_markets
process_markets(market_type: MarketType) -> None
Processes bets placed by agents on a given market.
Source code in prediction_market_agent_tooling/deploy/agent.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
after_process_markets
after_process_markets(market_type: MarketType) -> None
Executed after market processing loop ends.
Source code in prediction_market_agent_tooling/deploy/agent.py
470 471 472 473 | |
check_min_required_balance_to_trade
check_min_required_balance_to_trade(
market: AgentMarket,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
520 521 522 523 524 525 526 527 528 529 530 531 | |
get_total_amount_to_bet
staticmethod
get_total_amount_to_bet(market: AgentMarket) -> USD
Source code in prediction_market_agent_tooling/deploy/agent.py
533 534 535 536 537 538 539 540 541 | |
get_betting_strategy
get_betting_strategy(
market: AgentMarket,
) -> BettingStrategy
Override this method to customize betting strategy of your agent.
Given the market and prediction, agent uses this method to calculate optimal outcome and bet size.
Source code in prediction_market_agent_tooling/deploy/agent.py
543 544 545 546 547 548 549 550 | |
build_trades
build_trades(
market: AgentMarket,
answer: CategoricalProbabilisticAnswer,
existing_position: ExistingPosition | None,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/agent.py
552 553 554 555 556 557 558 559 560 | |
DeployableAlwaysRaiseAgent
DeployableAlwaysRaiseAgent(
enable_langfuse: bool = APIKeys().default_enable_langfuse,
store_predictions: bool = True,
store_trades: bool = True,
place_trades: bool = True,
)
Bases: DeployableTraderAgent
Source code in prediction_market_agent_tooling/deploy/agent.py
502 503 504 505 506 507 508 509 510 511 512 513 | |
start_time
instance-attribute
start_time = utcnow()
enable_langfuse
instance-attribute
enable_langfuse = enable_langfuse
api_keys
instance-attribute
api_keys = APIKeys()
session_id
cached
property
session_id: str
AGENT_TAG
class-attribute
instance-attribute
AGENT_TAG: AgentTagEnum = TRADER
bet_on_n_markets_per_run
class-attribute
instance-attribute
bet_on_n_markets_per_run: int = 1
n_markets_to_fetch
class-attribute
instance-attribute
n_markets_to_fetch: int = MAX_AVAILABLE_MARKETS
trade_on_markets_created_after
class-attribute
instance-attribute
trade_on_markets_created_after: DatetimeUTC | None = None
get_markets_sort_by
class-attribute
instance-attribute
get_markets_sort_by: SortBy = CLOSING_SOONEST
get_markets_filter_by
class-attribute
instance-attribute
get_markets_filter_by: FilterBy = OPEN
allow_invalid_questions
class-attribute
instance-attribute
allow_invalid_questions: bool = False
same_market_trade_interval
class-attribute
instance-attribute
same_market_trade_interval: TradeInterval = FixedInterval(
timedelta(hours=24)
)
min_balance_to_keep_in_native_currency
class-attribute
instance-attribute
min_balance_to_keep_in_native_currency: xDai | None = (
MINIMUM_NATIVE_TOKEN_IN_EOA_FOR_FEES
)
supported_markets
class-attribute
instance-attribute
supported_markets: Sequence[MarketType] = [
OMEN,
MANIFOLD,
POLYMARKET,
SEER,
]
store_predictions
instance-attribute
store_predictions = store_predictions
agent_name
property
agent_name: str
fetch_categorical_markets
property
fetch_categorical_markets: bool
store_trades
instance-attribute
store_trades = store_trades
place_trades
instance-attribute
place_trades = place_trades
answer_categorical_market
answer_categorical_market(
market: AgentMarket,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent_example.py
34 35 36 37 | |
initialize_langfuse
initialize_langfuse() -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
515 516 517 518 | |
langfuse_update_current_trace
langfuse_update_current_trace(
name: str | None = None,
input: Any | None = None,
output: Any | None = None,
user_id: str | None = None,
session_id: str | None = None,
version: str | None = None,
release: str | None = None,
metadata: Any | None = None,
tags: list[str] | None = None,
public: bool | None = None,
) -> None
Provide some useful default arguments when updating the current trace in our agents.
Source code in prediction_market_agent_tooling/deploy/agent.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
load
load() -> None
Implement this method to load arbitrary instances needed across the whole run of the agent.
Do not customize init method.
Source code in prediction_market_agent_tooling/deploy/agent.py
149 150 151 152 153 154 | |
deploy_local
deploy_local(
market_type: MarketType,
sleep_time: float,
run_time: float | None,
) -> None
Run the agent in the forever cycle every sleep_time seconds, until the run_time is met.
Source code in prediction_market_agent_tooling/deploy/agent.py
156 157 158 159 160 161 162 163 164 165 166 167 168 | |
run
run(market_type: MarketType) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
475 476 477 478 479 480 481 482 | |
get_gcloud_fname
get_gcloud_fname(market_type: MarketType) -> str
Source code in prediction_market_agent_tooling/deploy/agent.py
176 177 | |
update_langfuse_trace_by_market
update_langfuse_trace_by_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
224 225 226 227 228 229 230 231 232 233 234 235 | |
update_langfuse_trace_by_processed_market
update_langfuse_trace_by_processed_market(
market_type: MarketType,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
237 238 239 240 241 242 243 244 245 246 247 248 249 250 | |
check_min_required_balance_to_operate
check_min_required_balance_to_operate(
market_type: MarketType,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
256 257 258 259 260 261 262 | |
verify_market
verify_market(
market_type: MarketType, market: AgentMarket
) -> bool
Subclasses can implement their own logic instead of this one, or on top of this one. By default, it allows only markets where user didn't bet recently and it's a reasonable question.
Source code in prediction_market_agent_tooling/deploy/agent.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | |
answer_binary_market
answer_binary_market(
market: AgentMarket,
) -> ProbabilisticAnswer | None
Answer the binary market.
If this method is not overridden by the subclass, it will fall back to using answer_categorical_market(). Therefore, subclasses only need to implement answer_categorical_market() if they want to handle both types of markets.
Source code in prediction_market_agent_tooling/deploy/agent.py
302 303 304 305 306 307 308 309 310 311 312 | |
get_markets
get_markets(
market_type: MarketType,
) -> t.Sequence[AgentMarket]
Override this method to customize what markets will fetch for processing.
Source code in prediction_market_agent_tooling/deploy/agent.py
324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 | |
before_process_market
before_process_market(
market_type: MarketType, market: AgentMarket
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
562 563 564 565 566 | |
build_answer
build_answer(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> CategoricalProbabilisticAnswer | None
Source code in prediction_market_agent_tooling/deploy/agent.py
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 | |
process_market
process_market(
market_type: MarketType,
market: AgentMarket,
verify_market: bool = True,
) -> ProcessedTradedMarket | None
Source code in prediction_market_agent_tooling/deploy/agent.py
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 | |
after_process_market
after_process_market(
market_type: MarketType,
market: AgentMarket,
processed_market: ProcessedMarket | None,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
before_process_markets
before_process_markets(market_type: MarketType) -> None
Executed before market processing loop starts.
Source code in prediction_market_agent_tooling/deploy/agent.py
432 433 434 435 436 437 438 | |
process_markets
process_markets(market_type: MarketType) -> None
Processes bets placed by agents on a given market.
Source code in prediction_market_agent_tooling/deploy/agent.py
440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
after_process_markets
after_process_markets(market_type: MarketType) -> None
Executed after market processing loop ends.
Source code in prediction_market_agent_tooling/deploy/agent.py
470 471 472 473 | |
check_min_required_balance_to_trade
check_min_required_balance_to_trade(
market: AgentMarket,
) -> None
Source code in prediction_market_agent_tooling/deploy/agent.py
520 521 522 523 524 525 526 527 528 529 530 531 | |
get_total_amount_to_bet
staticmethod
get_total_amount_to_bet(market: AgentMarket) -> USD
Source code in prediction_market_agent_tooling/deploy/agent.py
533 534 535 536 537 538 539 540 541 | |
get_betting_strategy
get_betting_strategy(
market: AgentMarket,
) -> BettingStrategy
Override this method to customize betting strategy of your agent.
Given the market and prediction, agent uses this method to calculate optimal outcome and bet size.
Source code in prediction_market_agent_tooling/deploy/agent.py
543 544 545 546 547 548 549 550 | |
build_trades
build_trades(
market: AgentMarket,
answer: CategoricalProbabilisticAnswer,
existing_position: ExistingPosition | None,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/agent.py
552 553 554 555 556 557 558 559 560 | |
betting_strategy
GuaranteedLossError
Bases: RuntimeError
BettingStrategy
Bases: ABC
maximum_possible_bet_amount
abstractmethod
property
maximum_possible_bet_amount: USD
calculate_trades
abstractmethod
calculate_trades(
existing_position: ExistingPosition | None,
answer: CategoricalProbabilisticAnswer,
market: AgentMarket,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
42 43 44 45 46 47 48 49 | |
build_zero_usd_amount
staticmethod
build_zero_usd_amount() -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
56 57 58 | |
assert_buy_trade_wont_be_guaranteed_loss
staticmethod
assert_buy_trade_wont_be_guaranteed_loss(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
filter_trades
staticmethod
filter_trades(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
90 91 92 93 94 95 | |
MultiCategoricalMaxAccuracyBettingStrategy
MultiCategoricalMaxAccuracyBettingStrategy(bet_amount: USD)
Bases: BettingStrategy
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
163 164 | |
bet_amount
instance-attribute
bet_amount = bet_amount
maximum_possible_bet_amount
property
maximum_possible_bet_amount: USD
calculate_direction
staticmethod
calculate_direction(
market: AgentMarket,
answer: CategoricalProbabilisticAnswer,
) -> OutcomeStr
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
170 171 172 173 174 175 176 177 178 179 180 | |
get_other_direction
staticmethod
get_other_direction(
outcomes: Sequence[OutcomeStr], direction: OutcomeStr
) -> OutcomeStr
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
182 183 184 185 186 187 188 189 190 | |
calculate_trades
calculate_trades(
existing_position: ExistingPosition | None,
answer: CategoricalProbabilisticAnswer,
market: AgentMarket,
) -> list[Trade]
We place bet on only one outcome.
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
build_zero_usd_amount
staticmethod
build_zero_usd_amount() -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
56 57 58 | |
assert_buy_trade_wont_be_guaranteed_loss
staticmethod
assert_buy_trade_wont_be_guaranteed_loss(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
filter_trades
staticmethod
filter_trades(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
90 91 92 93 94 95 | |
MaxExpectedValueBettingStrategy
MaxExpectedValueBettingStrategy(bet_amount: USD)
Bases: MultiCategoricalMaxAccuracyBettingStrategy
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
163 164 | |
maximum_possible_bet_amount
property
maximum_possible_bet_amount: USD
bet_amount
instance-attribute
bet_amount = bet_amount
calculate_direction
staticmethod
calculate_direction(
market: AgentMarket,
answer: CategoricalProbabilisticAnswer,
) -> OutcomeStr
Returns the index of the outcome with the highest expected value.
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | |
calculate_trades
calculate_trades(
existing_position: ExistingPosition | None,
answer: CategoricalProbabilisticAnswer,
market: AgentMarket,
) -> list[Trade]
We place bet on only one outcome.
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 | |
build_zero_usd_amount
staticmethod
build_zero_usd_amount() -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
56 57 58 | |
assert_buy_trade_wont_be_guaranteed_loss
staticmethod
assert_buy_trade_wont_be_guaranteed_loss(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
filter_trades
staticmethod
filter_trades(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
90 91 92 93 94 95 | |
get_other_direction
staticmethod
get_other_direction(
outcomes: Sequence[OutcomeStr], direction: OutcomeStr
) -> OutcomeStr
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
182 183 184 185 186 187 188 189 190 | |
KellyBettingStrategy
KellyBettingStrategy(
max_bet_amount: USD,
max_price_impact: float | None = None,
)
Bases: BettingStrategy
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
256 257 258 | |
max_bet_amount
instance-attribute
max_bet_amount = max_bet_amount
max_price_impact
instance-attribute
max_price_impact = max_price_impact
maximum_possible_bet_amount
property
maximum_possible_bet_amount: USD
get_kelly_bet
staticmethod
get_kelly_bet(
market: AgentMarket,
max_bet_amount: USD,
direction: OutcomeStr,
other_direction: OutcomeStr,
answer: CategoricalProbabilisticAnswer,
override_p_yes: float | None = None,
) -> SimpleBet
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
calculate_trades
calculate_trades(
existing_position: ExistingPosition | None,
answer: CategoricalProbabilisticAnswer,
market: AgentMarket,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 | |
calculate_price_impact_for_bet_amount
calculate_price_impact_for_bet_amount(
outcome_idx: int,
bet_amount: CollateralToken,
pool_balances: list[OutcomeWei],
fees: MarketFees,
) -> float
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | |
calculate_bet_amount_for_price_impact
calculate_bet_amount_for_price_impact(
market: AgentMarket,
kelly_bet: SimpleBet,
direction: OutcomeStr,
) -> CollateralToken
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
build_zero_usd_amount
staticmethod
build_zero_usd_amount() -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
56 57 58 | |
assert_buy_trade_wont_be_guaranteed_loss
staticmethod
assert_buy_trade_wont_be_guaranteed_loss(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
filter_trades
staticmethod
filter_trades(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
90 91 92 93 94 95 | |
MaxAccuracyWithKellyScaledBetsStrategy
MaxAccuracyWithKellyScaledBetsStrategy(max_bet_amount: USD)
Bases: BettingStrategy
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
412 413 | |
max_bet_amount
instance-attribute
max_bet_amount = max_bet_amount
maximum_possible_bet_amount
property
maximum_possible_bet_amount: USD
adjust_bet_amount
adjust_bet_amount(
existing_position: ExistingPosition | None,
market: AgentMarket,
) -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
419 420 421 422 423 424 425 | |
calculate_trades
calculate_trades(
existing_position: ExistingPosition | None,
answer: CategoricalProbabilisticAnswer,
market: AgentMarket,
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |
build_zero_usd_amount
staticmethod
build_zero_usd_amount() -> USD
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
56 57 58 | |
assert_buy_trade_wont_be_guaranteed_loss
staticmethod
assert_buy_trade_wont_be_guaranteed_loss(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | |
filter_trades
staticmethod
filter_trades(
market: AgentMarket, trades: list[Trade]
) -> list[Trade]
Source code in prediction_market_agent_tooling/deploy/betting_strategy.py
90 91 92 93 94 95 | |
constants
MARKET_TYPE_KEY
module-attribute
MARKET_TYPE_KEY = 'market_type'
REPOSITORY_KEY
module-attribute
REPOSITORY_KEY = 'repository'
OWNER_KEY
module-attribute
OWNER_KEY = 'owner'
INVALID_OUTCOME_LOWERCASE_IDENTIFIER
module-attribute
INVALID_OUTCOME_LOWERCASE_IDENTIFIER = 'invalid'
YES_OUTCOME_LOWERCASE_IDENTIFIER
module-attribute
YES_OUTCOME_LOWERCASE_IDENTIFIER = 'yes'
NO_OUTCOME_LOWERCASE_IDENTIFIER
module-attribute
NO_OUTCOME_LOWERCASE_IDENTIFIER = 'no'
gcp
deploy
deploy_to_gcp
deploy_to_gcp(
gcp_fname: str,
function_file: str,
requirements_file: Optional[str],
extra_deps: list[str],
labels: dict[str, str] | None,
env_vars: dict[str, str] | None,
secrets: dict[str, str] | None,
memory: int,
entrypoint_function_name: str,
timeout: int,
) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/deploy.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
schedule_deployed_gcp_function
schedule_deployed_gcp_function(
function_name: str, cron_schedule: str
) -> None
Source code in prediction_market_agent_tooling/deploy/gcp/deploy.py
88 89 90 91 92 93 94 | |
run_deployed_gcp_function
run_deployed_gcp_function(
function_name: str,
) -> requests.Response
Source code in prediction_market_agent_tooling/deploy/gcp/deploy.py
97 98 99 100 | |
remove_deployed_gcp_function
remove_deployed_gcp_function(function_name: str) -> None
Source code in prediction_market_agent_tooling/deploy/gcp/deploy.py
103 104 105 106 | |
kubernetes_models
Metadata
Bases: BaseModel
creationTimestamp
instance-attribute
creationTimestamp: int
generation
instance-attribute
generation: int
name
instance-attribute
name: str
namespace
instance-attribute
namespace: str
resourceVersion
instance-attribute
resourceVersion: str
uid
instance-attribute
uid: str
labels
instance-attribute
labels: dict[str, str]
Metadata1
Bases: BaseModel
creationTimestamp
instance-attribute
creationTimestamp: int | None
name
instance-attribute
name: str
Metadata2
Bases: BaseModel
creationTimestamp
instance-attribute
creationTimestamp: int | None
name
instance-attribute
name: str
SecretKeyRef
Bases: BaseModel
key
instance-attribute
key: str
name
instance-attribute
name: str
optional
instance-attribute
optional: bool
ValueFrom
Bases: BaseModel
secretKeyRef
instance-attribute
secretKeyRef: SecretKeyRef
EnvItem
Bases: BaseModel
name
instance-attribute
name: str
valueFrom
instance-attribute
valueFrom: ValueFrom
ConfigMapRef
Bases: BaseModel
name
instance-attribute
name: str
optional
instance-attribute
optional: bool
EnvFromItem
Bases: BaseModel
configMapRef
instance-attribute
configMapRef: ConfigMapRef
Limits
Bases: BaseModel
cpu
instance-attribute
cpu: str
memory
instance-attribute
memory: str
Requests
Bases: BaseModel
cpu
instance-attribute
cpu: str
memory
instance-attribute
memory: str
Resources
Bases: BaseModel
limits
instance-attribute
limits: Limits
requests
instance-attribute
requests: Requests
Container
Bases: BaseModel
env
instance-attribute
env: list[EnvItem]
envFrom
instance-attribute
envFrom: list[EnvFromItem]
image
instance-attribute
image: str
imagePullPolicy
instance-attribute
imagePullPolicy: str
name
instance-attribute
name: str
resources
instance-attribute
resources: Resources
terminationMessagePath
instance-attribute
terminationMessagePath: str
terminationMessagePolicy
instance-attribute
terminationMessagePolicy: str
NodeSelector
Bases: BaseModel
role
instance-attribute
role: str
Toleration
Bases: BaseModel
effect
instance-attribute
effect: str
key
instance-attribute
key: str
operator
instance-attribute
operator: str
value
instance-attribute
value: str
Spec2
Bases: BaseModel
automountServiceAccountToken
instance-attribute
automountServiceAccountToken: bool
containers
instance-attribute
containers: list[Container]
dnsPolicy
instance-attribute
dnsPolicy: str
enableServiceLinks
instance-attribute
enableServiceLinks: bool
nodeSelector
instance-attribute
nodeSelector: NodeSelector
restartPolicy
instance-attribute
restartPolicy: str
schedulerName
instance-attribute
schedulerName: str
securityContext
instance-attribute
securityContext: dict[str, Any]
shareProcessNamespace
instance-attribute
shareProcessNamespace: bool
terminationGracePeriodSeconds
instance-attribute
terminationGracePeriodSeconds: int
tolerations
instance-attribute
tolerations: list[Toleration]
Template
Bases: BaseModel
metadata
instance-attribute
metadata: Metadata2
spec
instance-attribute
spec: Spec2
Spec1
Bases: BaseModel
activeDeadlineSeconds
instance-attribute
activeDeadlineSeconds: int
backoffLimit
instance-attribute
backoffLimit: int
completions
instance-attribute
completions: int
manualSelector
instance-attribute
manualSelector: bool
parallelism
instance-attribute
parallelism: int
template
instance-attribute
template: Template
JobTemplate
Bases: BaseModel
metadata
instance-attribute
metadata: Metadata1
spec
instance-attribute
spec: Spec1
Spec
Bases: BaseModel
concurrencyPolicy
instance-attribute
concurrencyPolicy: str
failedJobsHistoryLimit
instance-attribute
failedJobsHistoryLimit: int
jobTemplate
instance-attribute
jobTemplate: JobTemplate
schedule
instance-attribute
schedule: str
successfulJobsHistoryLimit
instance-attribute
successfulJobsHistoryLimit: int
suspend
instance-attribute
suspend: bool
timeZone
instance-attribute
timeZone: str
Status
Bases: BaseModel
lastScheduleTime
class-attribute
instance-attribute
lastScheduleTime: str | None = None
lastSuccessfulTime
class-attribute
instance-attribute
lastSuccessfulTime: str | None = None
KubernetesCronJob
Bases: BaseModel
apiVersion
instance-attribute
apiVersion: str
kind
instance-attribute
kind: str
metadata
instance-attribute
metadata: Metadata
spec
instance-attribute
spec: Spec
status
instance-attribute
status: Status
Metadata3
Bases: BaseModel
resourceVersion
instance-attribute
resourceVersion: str
KubernetesCronJobsModel
Bases: BaseModel
apiVersion
instance-attribute
apiVersion: str
items
instance-attribute
items: list[KubernetesCronJob]
kind
instance-attribute
kind: str
metadata
instance-attribute
metadata: Metadata3
utils
gcloud_deploy_cmd
gcloud_deploy_cmd(
gcp_function_name: str,
source: str,
entry_point: str,
labels: dict[str, str] | None,
env_vars: dict[str, str] | None,
secrets: dict[str, str] | None,
memory: int,
timeout: int = 180,
retry_on_failure: bool = False,
) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
gcloud_schedule_cmd
gcloud_schedule_cmd(
function_name: str, cron_schedule: str
) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
59 60 61 62 63 64 65 66 | |
gcloud_delete_function_cmd
gcloud_delete_function_cmd(fname: str) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
69 70 | |
gcloud_get_topics_cmd
gcloud_get_topics_cmd() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
73 74 | |
get_gcloud_topics
get_gcloud_topics() -> list[str]
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
77 78 79 80 81 82 83 84 85 86 87 88 | |
gcloud_create_topic_cmd
gcloud_create_topic_cmd(topic_name: str) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
91 92 | |
gcloud_delete_topic_cmd
gcloud_delete_topic_cmd(topic_name: str) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
95 96 | |
get_gcloud_project_id
get_gcloud_project_id() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
99 100 101 102 103 104 105 106 107 108 109 | |
get_gcloud_parent
get_gcloud_parent() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
112 113 | |
get_gcloud_id_token
get_gcloud_id_token() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
116 117 118 119 120 121 122 123 124 125 126 | |
get_gcloud_region
get_gcloud_region() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
129 130 | |
get_gcloud_python_runtime_str
get_gcloud_python_runtime_str() -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
133 134 | |
get_gcloud_function_uri
get_gcloud_function_uri(function_name: str) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
137 138 139 140 141 142 143 144 145 146 147 | |
api_keys_to_str
api_keys_to_str(api_keys: dict[str, str]) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
150 151 | |
list_gcp_functions
list_gcp_functions() -> list[Function]
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
154 155 156 157 | |
list_gcp_cronjobs
list_gcp_cronjobs(
namespace: str,
) -> KubernetesCronJobsModel
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
160 161 162 163 164 165 166 167 168 169 170 | |
get_gcp_configmap_data
get_gcp_configmap_data(
namespace: str, name: str
) -> dict[str, str]
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
173 174 175 176 177 178 179 180 181 182 183 184 | |
get_gcp_function
get_gcp_function(fname: str) -> Function
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
187 188 189 190 191 192 193 194 | |
gcp_function_is_active
gcp_function_is_active(fname: str) -> bool
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
197 198 | |
gcp_get_secret_value
cached
gcp_get_secret_value(
name: str, version: str = "latest"
) -> str
Source code in prediction_market_agent_tooling/deploy/gcp/utils.py
201 202 203 204 205 206 | |
trade_interval
TradeInterval
Bases: ABC
get
abstractmethod
get(market: AgentMarket) -> timedelta
Source code in prediction_market_agent_tooling/deploy/trade_interval.py
9 10 11 12 13 14 | |
FixedInterval
FixedInterval(interval: timedelta)
Bases: TradeInterval
For trades at a fixed interval.
Source code in prediction_market_agent_tooling/deploy/trade_interval.py
22 23 | |
interval
instance-attribute
interval = interval
get
get(market: AgentMarket) -> timedelta
Source code in prediction_market_agent_tooling/deploy/trade_interval.py
25 26 27 28 29 | |
MarketLifetimeProportionalInterval
MarketLifetimeProportionalInterval(max_trades: int)
Bases: TradeInterval
For uniformly distributed trades over the market's lifetime.
Source code in prediction_market_agent_tooling/deploy/trade_interval.py
37 38 | |
max_trades
instance-attribute
max_trades = max_trades
get
get(market: AgentMarket) -> timedelta
Source code in prediction_market_agent_tooling/deploy/trade_interval.py
40 41 42 43 44 45 46 | |