Tools to benchmark, deploy and monitor prediction market agents.
Prediction Market Agent Tooling
Tooling for benchmarking, deploying and monitoring agents for prediction market applications.
Setup
Install the project dependencies with poetry, using Python >=3.10:
python3.10 -m pip install poetry
python3.10 -m poetry install
python3.10 -m poetry shell
Create a .env file in the root of the repo with the following variables:
Deploying and monitoring agents using GCP requires that you set up the gcloud CLI (see here for installation instructions, and use gcloud auth login to authorize.)
MANIFOLDAPIKEY=...
BETFROMPRIVATE_KEY=...
OPENAIAPIKEY=...
Benchmarking
Create a benchmarkable agent by subclassing the AbstractBenchmarkedAgent base class, and plug in your agent's research and prediction functions into the predict method.
Use the Benchmarker class to compare your agent's predictions vs. the 'wisdom of the crowd' on a set of markets from your chosen prediction market platform.
For example:
import predictionmarketagent_tooling.benchmark.benchmark as bm
from predictionmarketagent_tooling.benchmark.agents import RandomAgent
from predictionmarketagenttooling.markets.markettype import MarketType
from predictionmarketagenttooling.markets.markets import getbinary_markets
benchmarker = bm.Benchmarker( markets=getbinarymarkets(limit=10, market_type=MarketType.MANIFOLD), agents=[RandomAgent(agentname="arandom_agent")], ) benchmarker.run_agents() md = benchmarker.generatemarkdownreport()
This produces a markdown report that you can use for comparing agents side-by-side, like:

Deploying
Deprecated: We suggest using your own infrastructure to deploy, but you may still find this useful.
Create a deployable agent by subclassing the DeployableTraderAgent base class, and implementing the answerbinarymarket method.
For example, deploy an agent that randomly picks an outcome:
import random
from predictionmarketagent_tooling.deploy.agent import DeployableTraderAgent
from predictionmarketagenttooling.markets.agentmarket import AgentMarket
class DeployableCoinFlipAgent(DeployableTraderAgent): def answerbinarymarket(self, market: AgentMarket) -> bool | None: return random.choice([True, False])
DeployableCoinFlipAgent().deploy_gcp(...)
Safe
Agents can control funds via a wallet primary key only, or optionally via a Safe as well. For deploying a Safe manually for a given agent, run the script below:
poetry run python scripts/createsafeforagent.py --from-private-key <YOURAGENTPRIVATEKEY> --salt-nonce 42
This will output the newly created Safe in the terminal, and it can then be copied over to the deployment part (e.g. Terraform). Note that saltnonce can be passed so that the created safe is deterministically created for each agent, so that, if the same saltnonce is used, the script will not create a new Safe for the agent, instead it will output the previously existent Safe.
You can then specify this agent's Safe address with the SAFE_ADDRESS environment variable.
Monitoring
Monitor the performance of the agents deployed to GCP, as well as meta-metrics of the prediction market platforms they are deployed to.
This runs as a streamlit app on a localhost server, executed with:
PYTHONPATH=. streamlit run examples/monitor/monitor.py
Which launches in the browser:

The Market Platforms
The following prediction market platforms are supported:
| Platform | Benchmarking | Deployment | Monitoring | |---------------------------------------|--------------|------------|------------| | Manifold | ✅ | ✅ | ✅ | | AIOmen | ✅ | ✅ | ✅ | | Polymarket | ✅ | ❌ | ❌ |
Prediction Markets Python API
We have built clean abstractions for taking actions on the different prediction market platforms (retrieving markets, buying and selling tokens, etc.). This is currently undocumented, but for now, inspecting the AgentMarket class and its methods is your best bet.
For example:
from predictionmarketagent_tooling.config import APIKeys
from predictionmarketagenttooling.markets.agentmarket import SortBy
from predictionmarketagent_tooling.markets.omen.omen import OmenAgentMarket
Place a bet on the market closing soonest
market = OmenAgentMarket.getmarkets(limit=1, sortby=SortBy.CLOSING_SOONEST)[0]
market.placebet(outcome=True, amount=market.getbet_amount(0.1))
View your positions
mypositions = OmenAgentMarket.getpositions(userid=APIKeys().betfrom_address)
print(my_positions)
Sell position (accounting for fees)
market.selltokens(outcome=True, amount=market.getbet_amount(0.095))
This API can be built on top of to create your application. See here for an example.
Contributing
See the Issues for ideas of things that need fixing or implementing. The team is also receptive to new issues and PRs.
We use mypy for static type checking, and isort, black and autoflake for linting, and pre-commit to minimise unwanted pushes to the public repositories. These all run as steps in CI, but pre-commit also needs to be installed locally using the provided install_hooks.sh script.