Skip to content

Example: Swarms + Polymarket & Kalshi — Agentic Prediction Market Trading #5

@kyegomez

Description

@kyegomez

Overview

Add a tutorial in the examples section showing how to build autonomous prediction market agents using Swarms with the Polymarket and Kalshi APIs. Agents should be able to discover events, reason about outcomes, and place bets programmatically.

References:


What to Cover

1. Market Discovery

  • Querying Polymarket and Kalshi for open markets/events
  • Filtering events by category (politics, sports, crypto, economics, etc.)
  • Parsing event metadata: question, resolution criteria, end date, current odds

2. Single-Agent Pattern

  • An agent that fetches events, reasons about probability using LLM judgment, and decides whether to bet
  • Example prompt chain: fetch markets → summarize event → estimate probability → compare to market odds → execute if edge exists

3. Multi-Agent Swarm Pattern

  • Research Agent — fetches news and context about an event
  • Analyst Agent — estimates true probability of an outcome
  • Risk Agent — checks position size, exposure limits, bankroll management
  • Execution Agent — places the bet via Polymarket CLOB API or Kalshi REST API

4. Code Examples

  • Connecting to Polymarket's CLOB API (order placement, balance check)
  • Connecting to Kalshi's REST API (create order, get positions)
  • Full end-to-end working Python example with Swarms

5. Guardrails & Best Practices

  • Max bet size limits
  • Logging all agent decisions and trades
  • Dry-run / simulation mode before live trading

Suggested File Location

examples/integrations/swarms-polymarket-kalshi-prediction-markets.mdx


Acceptance Criteria

  • Working Python code examples for both Polymarket and Kalshi
  • Covers single-agent and multi-agent swarm patterns
  • Includes setup/prerequisites (API keys, wallet setup for Polymarket, dependencies)
  • Added to the examples navigation in docs.json
  • Guardrails section included for responsible autonomous betting

Labels

documentation, example, integrations

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions