Skip to main content

Autonomous AI trading agent for prediction markets (Polymarket, Kalshi): finds edge, manages risk, trades, and learns.

Project description

OpenThomas — AI trading agent for prediction markets

An autonomous AI agent that trades Polymarket and Kalshi for you: it scans thousands of markets, forecasts with an LLM ensemble, sizes positions with fractional Kelly, and enforces risk limits the model can't override. You set the bankroll, the risk profile, and the goal. It does the rest — and learns from every settled trade.

pip install openthomas
openthomas init --bankroll 1000 --risk conservative
openthomas run        # paper trading on live market prices — the default

No wallet, no exchange API keys needed to start: paper mode simulates fills against real Polymarket + Kalshi order books. You only connect real money after you've watched it trade.

⚠️ Prediction market trading can lose all the money you allocate. OpenThomas ships with paper trading as the default, hard position limits, and a drawdown kill-switch — but no software makes trading safe. Roughly 70% of Polymarket addresses have lost money. This is not financial advice.


Why another trading bot? Because the LLM is not the edge.

The Prediction Arena benchmark gave six frontier AI models $10,000 each and let them trade real prediction markets autonomously for 57 days. Every single one lost money — between −16% and −30.8%. Research volume didn't matter. Token spend didn't matter. What separated the least-bad from the worst:

  1. Initial prediction accuracy — being right, early
  2. Sizing up when correct, down when uncertain
  3. Exit discipline — early exits systematically underperformed holding to settlement
  4. Not trading at all when there's no edge

The only profitable run on record (+10.9%) was selective (112 trades), asymmetric (avg win $63.89 vs avg loss $3.23), and low-drawdown (4.1%). That profile is a harness property, not a model property. OpenThomas is that harness:

Layer What it does Who's in control
Edge scanner Filters thousands of markets down to plausible mispricings; flags cross-platform arbitrage (Polymarket vs Kalshi price gaps) deterministic code
Forecast engine LLM ensemble (median of N independent estimates), grounded in resolution rules and base rates your choice of model
Calibration layer Platt-scales raw forecasts against your own settled-trade history; blends with the market price (pure LLM forecasts lose to market consensus; a blend beats it) deterministic code
Risk engine Fractional Kelly sizing, per-market / per-event / per-category caps, fee-aware EV threshold, longshot-zone filter, drawdown kill-switch deterministic code — the model proposes, the risk engine disposes
Memory Every forecast and fill journaled to SQLite; post-settlement reflection distills lessons that feed back into future prompts agent, human-auditable

What it looks like

$ openthomas run --once
────────────── cycle · account $1,004.12 · cash $861.40 ──────────────
markets 300 → candidates 58 → forecasts 12 → trades 2
  TRADE BUY 41 NO @ 0.34 [polymarket] Will the Fed cut rates in September?
  TRADE BUY 28 YES @ 0.61 [kalshi] Will CPI YoY be above 2.8% in July?
  ARB? +0.045 gap | polymarket:Fed cuts in September vs kalshi:Fed decision Sept
  skip: Will Spain win the World Cup?: edge +0.021 below threshold 0.080
  skip: Putin out by Dec 31?: confidence 0.40 too low
$ openthomas report
Account value: $1,041.87  (start $1,000.00, +4.2%)
Settled: 31 · win rate 61% · avg win $4.10 / avg loss $1.35
Brier score: 0.191 (0.25 = coin flip, lower is better)

openthomas vital renders a shareable performance card (equity curve, win rate, Brier score, max drawdown) — post your track record, good or bad.

Quickstart

pip install openthomas

# 1. Configure: bankroll, risk appetite, goal, forecasting model
openthomas init --bankroll 1000 --risk conservative \
  --goal "Grow steadily; protecting capital beats chasing returns"
export ANTHROPIC_API_KEY=sk-ant-...   # or any OpenAI-compatible endpoint

# 2. See what it sees
openthomas scan

# 3. Let it trade (paper mode: real prices, simulated fills)
openthomas run

# 4. Check in
openthomas report
openthomas vital

Local / self-hosted models (no API bill, full privacy):

openthomas init --provider openai --base-url http://localhost:11434/v1 --model gemma3:12b

Any OpenAI-compatible server works — Ollama, vLLM, llama.cpp. If you have GPUs, docs/TRAINING.md covers fine-tuning a local model on your own trade journal (calibration LoRA) so the agent's forecaster improves on your markets.

Use it from Claude (MCP)

Your agent brings the market view; OpenThomas enforces the discipline:

pip install 'openthomas[mcp]'
claude mcp add openthomas -- openthomas-mcp

Now Claude (or OpenClaw, Hermes, any MCP client) can scan markets, pull news, and propose_trade — every proposal is blended with the market price, sized with fractional Kelly, and checked against hard exposure caps before a paper fill. Rejections name the binding constraint. See docs/MCP.md.

Risk profiles

You hand OpenThomas a mandate, not a suggestion — these are enforced in deterministic code, outside the LLM:

conservative moderate aggressive
Kelly fraction 0.15× 0.25× 0.33×
Max per market 5% 8% 12%
Min edge after fees
Drawdown kill-switch 15% 20% 30%
Max trades/cycle 3 5 8

Plus, in every profile: per-event correlation caps (correlated settlements caused the largest single-session losses in Prediction Arena), longshot-zone filter (contracts under 10¢ lose >60% of stake on average — Whelan et al. 2026), solvency checks including fees, and mark-to-market at bid prices (liquidation value, not hope).

How it learns

  • Journal — every forecast, fill, and settlement in SQLite (~/.openthomas/journal.db). Your data, on your machine.
  • Calibration — once ≥30 markets settle, OpenThomas fits Platt scaling per category to correct your model's systematic bias (e.g. "runs 10 points hot on weather").
  • Lessons — after settlements, a reflection pass writes short falsifiable rules to ~/.openthomas/lessons/, which are injected into future forecast prompts.
  • Skills — strategies and domain playbooks are markdown files (skills/), the same pattern as OpenClaw / Hermes / Claude skills. Add your own, or let the agent draft one from its post-mortems for you to approve.

FAQ

Can an AI bot actually make money on Polymarket or Kalshi? Unproven for pure LLM forecasting — every frontier model tested in live benchmarks lost money, and no rigorous public demonstration of sustained fee-adjusted LLM alpha exists. The documented, durable edges are structural: longshot-bias fading, cross-platform arbitrage, market-making spread capture, and researched divergence trades in illiquid long-tail markets. OpenThomas is built to exploit those with LLM research as an input — and to decline to trade the rest. Paper-trade first. Expect losses.

Do I need API keys to try it? No exchange keys. Paper mode uses public market data from both venues. You need an LLM (API key or a local model via Ollama) for forecasting.

Which markets does it trade? Binary markets on Polymarket (global, crypto-settled in pUSD) and Kalshi (US, CFTC-regulated). Kalshi's demo exchange is supported (KALSHI_DEMO=1). Live Polymarket trading from the US is geoblocked to close-only on the offshore CLOB; Polymarket US is a separate venue (integration planned).

Can it withdraw or move my funds? No. The agent only trades within the bankroll you allocate. It has no withdrawal, transfer, or deposit capability — and live mode requires two independent explicit switches.

What models work best? Any strong reasoning model via Anthropic or OpenAI-compatible APIs. Local Gemma-class models (12B+) work for the privacy-conscious; expect weaker forecasts until you fine-tune on your journal (see docs/TRAINING.md).

Documentation

Roadmap

  • Paper trading loop on live Polymarket + Kalshi data
  • LLM ensemble forecasting, calibration, market-prior blending
  • Deterministic risk engine (Kelly, caps, kill-switch)
  • Cross-platform arbitrage scanner
  • Journal, lessons, shareable vital card
  • Live Kalshi execution hardening (order amend/cancel, WebSocket fills)
  • Polymarket live execution via official SDK (pUSD)
  • NegRisk / multi-outcome coherence arbitrage
  • Market-making strategy (maker rebates + liquidity incentive programs)
  • News retrieval pipeline for forecasts (GDELT + Google News, keyless)
  • MCP server — Claude/any agent brings the view, OpenThomas enforces risk (docs)
  • Web dashboard, Telegram/Discord notifications
  • Journal → LoRA fine-tuning recipes for local models
  • Public community leaderboard of (opt-in) vitals

Contributing

The interesting problems are open: retrieval quality, resolution-rule matching for cross-venue arbitrage, calibration under small samples, market-making without adverse selection. PRs welcome — see CONTRIBUTING.md. If you run OpenThomas, share your vital card in Discussions — including the losses; honest track records are how this gets better.

License

MIT. Trade at your own risk; comply with your local laws and each venue's terms.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openthomas-0.1.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openthomas-0.1.0-py3-none-any.whl (44.1 kB view details)

Uploaded Python 3

File details

Details for the file openthomas-0.1.0.tar.gz.

File metadata

  • Download URL: openthomas-0.1.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for openthomas-0.1.0.tar.gz
Algorithm Hash digest
SHA256 915934c8344bc7d2afa264c3eef6c0906415f4a8194e4263b801c48386d986c2
MD5 e893563849e22736da5609ad5003ec07
BLAKE2b-256 907fe75f155a91b242bf044360726eaf3ef955e09e0b1d6e9cd25284bce7a98c

See more details on using hashes here.

File details

Details for the file openthomas-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openthomas-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 44.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for openthomas-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 11bbe34a9e70693b17e239cf0998b80d633547c25d3eb5b795948a8064ef36d3
MD5 7a5e38d6e2f14ca89a89dc91f07c386c
BLAKE2b-256 8b900688b0d41765e899ccf2daeac8c9c6a22d25247ee8a3b91c93bcafa2515c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page