Skip to main content

Overview

The easiest way to create your own agent that places bets on prediction markets is to subclass the DeployableTraderAgent class. This guide walks you through creating a custom agent, using the DeployableCoinFlipAgent as a minimal example.

Prerequisites

Before creating your agent, ensure you have:
  • Python 3.11 or higher installed
  • The repository set up with dependencies installed via Poetry
  • Required API keys configured in your .env file

Understanding DeployableTraderAgent

The DeployableTraderAgent is the base class that provides the framework for creating trading agents. Your custom agent needs to implement two key methods:
  1. verify_market() - Validates whether the agent should trade on a given market
  2. answer_binary_market() - Returns a prediction for a binary market question

Example: CoinFlip Agent

Let’s examine the simplest possible agent - one that makes random predictions:
prediction_market_agent/agents/coinflip_agent/deploy.py

Key Components

This method determines whether your agent should trade on a specific market.
You can add custom logic here to filter markets based on:
  • Market type (Omen, Manifold, Polymarket)
  • Question content
  • Liquidity levels
  • Time until market close
This method generates your agent’s prediction for a binary market.
The ProbabilisticAnswer contains:
  • p_yes: Probability that the answer is “Yes” (0.0 to 1.0)
  • confidence: How confident the agent is in this prediction (0.0 to 1.0)
  • reasoning: Explanation for the prediction

Advanced Configuration

You can customize your agent’s behavior with additional configuration:

Configuration Options

Creating an Evidence-Based Agent

For a more sophisticated agent that uses real data, examine the AdvancedAgent:
prediction_market_agent/agents/advanced_agent/deploy.py
1

Search for Information

Use search_google_serper() to find relevant URLs about the market question.
2

Scrape Content

Extract text content from the top URLs using web_scrape().
3

Analyze with LLM

Pass the question and scraped content to an LLM to generate a probability and confidence score.
4

Return Prediction

Return a ProbabilisticAnswer with the prediction results.

Registering Your Agent

Once you’ve created your agent, register it in prediction_market_agent/run_agent.py:
1

Add to RunnableAgent Enum

2

Add to RUNNABLE_AGENTS Dict

3

Import Your Agent

Running Your Agent

Execute your agent using the command line:
Replace omen with your target market type: omen, manifold, polymarket, or metaculus.

Best Practices

Start Simple

Begin with a simple agent like DeployableCoinFlipAgent to understand the framework, then add complexity.

Use Evidence

Implement data gathering from reliable sources (APIs, web scraping) for better predictions.

Handle Errors

Return None from answer_binary_market() when you can’t make a reliable prediction.

Log Everything

Use the logger to track your agent’s decisions for debugging and improvement.

Next Steps

Deploy Your Agent

Learn how to deploy your agent to production

Benchmark Performance

Test your agent’s accuracy against human traders