Overview
The easiest way to create your own agent that places bets on prediction markets is to subclass theDeployableTraderAgent 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
.envfile
Understanding DeployableTraderAgent
TheDeployableTraderAgent is the base class that provides the framework for creating trading agents. Your custom agent needs to implement two key methods:
verify_market()- Validates whether the agent should trade on a given marketanswer_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
verify_market() Method
verify_market() Method
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
answer_binary_market() Method
answer_binary_market() Method
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
| Parameter | Description | Default |
|---|---|---|
bet_on_n_markets_per_run | Number of markets to trade on per execution | Varies by agent |
get_markets_sort_by | How to sort available markets | SortBy.NONE |
same_market_trade_interval | Minimum time between trades on the same market | - |
trade_on_markets_created_after | Only trade on markets created after this date | - |
Creating an Evidence-Based Agent
For a more sophisticated agent that uses real data, examine theAdvancedAgent:
prediction_market_agent/agents/advanced_agent/deploy.py
Analyze with LLM
Pass the question and scraped content to an LLM to generate a probability and confidence score.
Registering Your Agent
Once you’ve created your agent, register it inprediction_market_agent/run_agent.py:
Running Your Agent
Execute your agent using the command line: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