Skip to main content

Overview

The DeployableCoinFlipAgent is a simple agent that makes random binary predictions using a coin flip mechanism. This agent serves as a baseline for testing and comparison purposes.

Class: DeployableCoinFlipAgent

A basic trading agent that randomly predicts market outcomes with 50/50 probability.

Inheritance

DeployableCoinFlipAgent(DeployableTraderAgent)

Methods

verify_market

def verify_market(self, market_type: MarketType, market: AgentMarket) -> bool
Verifies if the agent should process a given market. This implementation accepts all markets.
market_type
MarketType
The type of prediction market
market
AgentMarket
The market to verify
return
bool
Always returns True

answer_binary_market

def answer_binary_market(self, market: AgentMarket) -> ProbabilisticAnswer | None
Generates a random prediction for a binary market by flipping a coin.
market
AgentMarket
The market to predict on
return
ProbabilisticAnswer | None
A probabilistic answer with:
  • p_yes: 0.0 or 1.0 (randomly chosen)
  • confidence: 0.5
  • reasoning: “I flipped a coin to decide.”

Class: DeployableCoinFlipAgentByHighestLiquidity

An enhanced version of the coin flip agent that targets high-liquidity markets.

Inheritance

DeployableCoinFlipAgentByHighestLiquidity(DeployableCoinFlipAgent)

Configuration Properties

get_markets_sort_by
SortBy
default:"SortBy.HIGHEST_LIQUIDITY"
Sorts markets by liquidity, targeting the most liquid markets first
bet_on_n_markets_per_run
int
default:"2"
Number of markets to trade on per execution run
same_market_trade_interval
TradeInterval
default:"FixedInterval(timedelta(days=14))"
Minimum time interval between trades on the same market (14 days)

Usage Examples

Basic CoinFlip Agent

from prediction_market_agent.agents.coinflip_agent.deploy import DeployableCoinFlipAgent
from prediction_market_agent_tooling.markets.markets import MarketType

# Initialize the agent
agent = DeployableCoinFlipAgent()

# Deploy locally for testing
agent.deploy_local(
    market_type=MarketType.OMEN,
    sleep_time=180,  # 3 minutes
)

High Liquidity CoinFlip Agent

from prediction_market_agent.agents.coinflip_agent.deploy import (
    DeployableCoinFlipAgentByHighestLiquidity
)
from prediction_market_agent_tooling.markets.markets import MarketType

# Initialize the agent with liquidity targeting
agent = DeployableCoinFlipAgentByHighestLiquidity()

# Deploy to production
agent.deploy(
    market_type=MarketType.OMEN,
    enable_langfuse=True,
)

Custom Configuration

from prediction_market_agent.agents.coinflip_agent.deploy import DeployableCoinFlipAgent
from prediction_market_agent_tooling.markets.agent_market import AgentMarket

# Subclass for custom behavior
class MyCoinFlipAgent(DeployableCoinFlipAgent):
    def verify_market(self, market_type: MarketType, market: AgentMarket) -> bool:
        # Only trade on markets with specific criteria
        return market.volume > 100

agent = MyCoinFlipAgent()
agent.deploy_local(market_type=MarketType.OMEN)

Implementation Details

Random Selection Mechanism

The agent uses Python’s random.choice() to make binary decisions:
import random

decision = random.choice([True, False])
p_yes = Probability(float(decision))  # 0.0 or 1.0

Source Location

prediction_market_agent/agents/coinflip_agent/deploy.py

Use Cases

  1. Baseline Testing: Compare more sophisticated agents against random predictions
  2. Market Activity: Generate trading activity for testing market infrastructure
  3. Control Group: Use as a control in agent performance studies
  4. Educational: Simple example for understanding the agent architecture

Build docs developers (and LLMs) love