An AWS Lambda bot that reads live Polymarket tech markets, forms an independent probability estimate with Claude, and places bets when it sees edge — with a homegrown insider-trading detector as a defensive filter.
Every 15 minutes, a Lambda:
- Fetches all live Polymarket markets from the Gamma API and filters to tech-category markets with liquidity above $10k.
- Pulls recent whale trades from the Polymarket subgraph and computes a per-market "manipulation score" from three signals — dormant wallets, abnormal size z-scores, and proximity to resolution — then builds a blacklist of markets that look like insider-tradey bets.
- Runs the markets through a two-tier Claude cascade:
- Haiku 4.5 picks a shortlist of 3–5 markets worth a deeper look.
- Sonnet 4.6 forms its own probability estimate for each shortlisted market, compares it to the public price, and emits a
BUY/SELL/SKIPdecision with confidence and rationale.
- Passes each non-SKIP decision through a risk guardrail (per-trade, daily, and open-exposure caps), then either paper-logs it or signs and submits the order via
py-clob-client. - Records every decision in DynamoDB and S3 for audit.
- Runs a bug-detection circuit breaker — halts automatically on slippage spikes, consecutive API errors, or parse failures (but not on losing trades — losing trades are the game).
Every run costs about three cents in Bedrock tokens. The whole thing stays under a dollar a day on AWS.
From the first real run:
Market: "Will GPT-6 be released before GTA VI?" Market price (YES): 0.675 Claude Sonnet's estimate: ~0.42 Decision: BUY NO at 0.325 (edge ≈ 0.25 vs 0.08 threshold) Rationale: "GTA VI has a confirmed 2025 release window, making it likely to release before GPT-6 which has no announced date and would follow GPT-5. Even accounting for GTA VI delay risk, the current NO price offers significant edge." Requested stake: $20 Guardrail final stake: $10 (confidence 0.72 < 0.85 high-conviction threshold)
EventBridge (every 15 min)
│
▼
┌────────────────────────────────────────────────────────────┐
│ Lambda: polybot-bot │
│ │
│ 1. Breaker check (DynamoDB state flag) │
│ 2. Gamma API → active markets │
│ 3. Filter: tech category + liquidity ≥ $10k │
│ 4. Subgraph → recent whale trades → suspicion score │
│ 5. Haiku filter → shortlist │
│ 6. Sonnet decider → per-market decision │
│ 7. Guardrails: $10/trade, $100/day, $400 exposure │
│ 8. Paper mode: log only. Live mode: py-clob-client sign+submit │
│ 9. Slippage check, error streak check → maybe trip breaker │
│ 10. Persist decision to DynamoDB + S3 ledger │
└────────────────────────────────────────────────────────────┘
│ │
▼ ▼
DynamoDB tables S3 ledger bucket
(state, decisions, trades) (one JSON per decision)
│
▼
CloudWatch alarms → SNS → email
Everything is one-region (us-east-1), one IAM blast radius, all infra-as-code in AWS CDK. There is no UI — the bot is a daemon.
| Param | Value |
|---|---|
| Max per trade | $10 |
| Max per trade (confidence ≥ 0.85) | $25 |
| Max daily spend | $100 |
| Max total open exposure | $400 |
| Min market liquidity | $10,000 |
| Categories | Tech only |
The bot ships in paper mode. PAPER_MODE=true logs every decision and computes would-be PnL but skips the order-signing step entirely. Flipping to live requires 7+ days of paper trading review — see DEPLOY.md for the cutover checklist.
One important design choice: the insider-trading detector here is used as a defensive filter, not as a signal to follow. By the time a dormant wallet's bet lands on-chain, the price has already moved. Copying it is slow. The detector is used to avoid markets that look like they've been front-run, and Sonnet is told in its system prompt to almost always SKIP blacklisted markets.
The actual edge (if there is one) comes from Claude's independent reasoning about public information, not from chasing whales.
- Runtime: Python 3.11 on AWS Lambda (Docker container image)
- Models: Anthropic Claude Haiku 4.5 + Sonnet 4.6 via AWS Bedrock (cross-region inference profiles)
- Storage: DynamoDB (state + decisions + trades), S3 (ledger), Secrets Manager (wallet key)
- Scheduling: EventBridge rule, 15-minute rate
- Observability: CloudWatch alarms, SNS alerts
- Trading SDK:
py-clob-clientfor Polymarket CLOB order signing - Infra: AWS CDK (Python) — 4 stacks:
DataStack,SecretsStack,ObservabilityStack,ComputeStack - Tests: 62 passing, end-to-end integration test with
moto+respx(no real AWS, no real network)
python -m venv .venv
source .venv/Scripts/activate # Git Bash on Windows
pip install -e ".[dev]"
pytest -vAWS_DEFAULT_REGION=us-east-1 cdk bootstrap
AWS_DEFAULT_REGION=us-east-1 cdk deploy --all --require-approval neverFull runbook (including secret population and the cutover gate) is in DEPLOY.md.
- Wallet private key lives in AWS Secrets Manager, never in code or
.envcommitted to the repo. .envis gitignored and carries only local dev configuration.- The bot is read-only against Polygon except for the trading wallet it controls.
- Bedrock IAM is scoped to specific Claude inference profile ARNs — not blanket
bedrock:*. - The cross-region inference profile requires
aws-marketplace:ViewSubscriptionson the Lambda execution role.
A weekend-scale project. The bankroll is small, the code is opinionated, and the primary value is the shape of the system: an AWS-native, Claude-powered autonomous agent with real money on the line, proper guardrails, an audit trail, and a paper-trading gate before any live risk. If you want to clone it and point it at a different bankroll or a different category, most of the work is swapping three constants and editing one prompt.
Financial advice. Not even close. Prediction markets are a zero-sum game against other humans and bots that have had more time to think about them than you. You will probably lose your bankroll. I'm okay with that.