Skip to main content

Overview

Once you’ve created and tested your agent, you can deploy it to production to trade on live prediction markets. This guide covers deployment strategies, configuration, and best practices.

Deployment Architecture

The Prediction Market Agent framework is designed to run as scheduled jobs in cloud environments, particularly Google Kubernetes Engine (GKE).

Key Components

run_agent.py

Main entrypoint that orchestrates agent execution

DeployableAgent

Base class that handles market selection and trading

Environment Variables

API keys and configuration stored securely

Market APIs

Integration with Omen, Manifold, and Polymarket

Prerequisites

1

Environment Setup

Ensure your .env file contains all required API keys:
.env
2

Test Locally

Run your agent locally to verify it works correctly:
3

Verify Market Access

Confirm your agent can connect to the target market platform and retrieve markets.

Deployment Process

1. Register Your Agent

Ensure your agent is registered in run_agent.py:
prediction_market_agent/run_agent.py

2. Configure Agent Parameters

Set deployment-specific parameters in your agent class:

3. Implement Betting Strategy

For production agents, implement a proper betting strategy to manage risk:
Without implementing get_betting_strategy(), your agent will place only tiny test bets by default.

4. Local Deployment

For simple deployments, run your agent as a scheduled cron job:

5. Cloud Deployment (GKE)

For production deployments, use Google Kubernetes Engine:
1

Create Docker Container

Dockerfile
2

Build and Push Image

3

Create Kubernetes CronJob

cronjob.yaml
4

Deploy to Cluster

Environment Variables

Required environment variables for deployment:

Wallet Setup

Your agent needs a wallet with funds to place bets:
1

Create Wallet

Set up a wallet on Gnosis Chain using MetaMask:
  • Install MetaMask browser extension
  • Create a new wallet or import existing
  • Save the private key securely
2

Add Gnosis Chain Network

Configure MetaMask for Gnosis Chain:
  • Click network selector in top left
  • Click “Add a custom network”
  • Enter network details:
3

Fund Wallet

Get xDai tokens for placing bets:
  • Bridge from Ethereum mainnet
  • Use a faucet for testing
  • Contact team for hackathon funds
4

Set Private Key

Add your wallet’s private key to .env:
Never commit your private key to version control!

Monitoring and Observability

Dune Dashboard

Track your deployed agent’s performance on the Dune Dashboard:
  • Total bets placed
  • Win rate and profitability
  • Gas costs and fees
  • Historical performance

Presagio Leaderboard

View your agent’s ranking on the Presagio Leaderboard with:
  • Success rate percentage
  • Total profits/losses
  • Number of markets traded
  • Comparison with other agents

Logging

Implement comprehensive logging in your agent:

Production Best Practices

Start Small

Begin with small bet amounts (1-5 xDai) until your agent proves profitable.

Monitor Performance

Check Dune Dashboard and logs daily to catch issues early.

Rate Limits

Respect API rate limits to avoid service disruptions.

Error Handling

Implement robust error handling to prevent crashes.

Security

Store private keys securely using secrets management.

Cost Management

Track API costs (OpenAI, Tavily) to maintain profitability.

Troubleshooting

Possible causes:
  • Insufficient wallet balance
  • Markets don’t pass verify_market() checks
  • API keys are invalid
  • Network connectivity issues
Solutions:
  • Check wallet balance on block explorer
  • Review verify_market() logic
  • Verify all API keys are correct
  • Test network connectivity
Possible causes:
  • Too many LLM calls per prediction
  • Using expensive models (GPT-4)
  • Trading on too many markets
Solutions:
  • Reduce bet_on_n_markets_per_run
  • Switch to cheaper models (GPT-4o-mini)
  • Implement caching for repeated queries
  • Limit web scraping depth
Possible causes:
  • Poor data sources
  • Inadequate prompt engineering
  • Not enough context for LLM
Solutions:
  • Improve web scraping quality
  • Refine prompts with more specific instructions
  • Increase context window
  • Study successful agents like ProphetGPT4o

Example: Prophet GPT-4o Agent

Here’s a production-ready agent configuration from the leaderboard:
This agent has achieved:
  • 60% success rate
  • $834+ in profits
  • Top ranking on the leaderboard

Next Steps

Benchmark Your Agent

Test performance against human traders

Join the Community

Get help and share insights