# Octagon CLI | Trade prediction markets from your terminal

AI-powered Kalshi trading CLI. Natural-language agent, edge detection vs. live order book, half-Kelly sizing, diversified baskets — all from your terminal. Powered by the Octagon Research API.

Prediction Markets CLI · Powered by Octagon
 #
Trade prediction markets from your terminal.

An AI agent that researches every Kalshi market, finds edge against the live order book, and executes trades — all behind a single CLI. Half-Kelly sizing. Five-gate risk engine. Diversified basket construction in one call.

  $ bunx kalshi-trading-bot-cli@latest    Copy    [
View on GitHub
](https://github.com/OctagonAI/kalshi-trading-bot-cli) [
Read the guide →
](https://github.com/OctagonAI/kalshi-trading-bot-cli/blob/main/GUIDE.md)    21 Octagon endpoints wired in   5 Risk gates before each fill   1 Command to build a basket          ~/kalshi-bot — bun · kalshi    $ bunx kalshi-trading-bot-cli@latest Welcome to Kalshi Trading Bot CLI Type help for commands, or just ask a question.   >    > search crypto    KXBTC-26APR-B95000 Bitcoin above $95k by Apr 30 $0.58 12,841   KXBTC-26APR-B100000 Bitcoin above $100k by Apr 30 $0.31 8,203   KXETH-26APR-B2000 Ethereum above $2k by Apr 30 $0.72 5,419  3 markets found   > analyze KXBTC-26APR-B95000   Octagon Research Report — KXBTC-26APR-B95000 ──────────────────────────────────────── Model Probability 72% Market Price 58% Edge +14.0% (very_high confidence)   Top Drivers 1. Bitcoin ETF inflows accelerating impact: high 2. Halving cycle momentum impact: high 3. Macro risk-on sentiment impact: moderate   Kelly Sizing Recommended: 3 contracts YES at $0.58 Risk gates: ✓ Kelly ✓ Liquidity ✓ Correlation ✓ Concentration ✓ Drawdown           What it does ## A research analyst, risk manager, and order router — in one binary.
       ### AI agent loop
 Natural-language queries trigger up to 10 tool-use iterations across Kalshi and Octagon endpoints. Bring your own LLM key — OpenAI, Anthropic, Google, xAI, OpenRouter, or local Ollama.

      ### Edge detection
 Octagon's model probability minus the live order book = edge. Surfaced per market, ranked across the universe, and sized with half-Kelly behind five risk gates before a dollar is risked.

      ### Diversified baskets
 One-call basket construction with thematic-cluster caps and pairwise correlation caps. Backtest a theme, Kelly-size it, validate cluster overlap — all server-side.

        Live commands ## From "I have an idea" to a filled order in four lines.
     01 ### Discover
 Server-side full-text + semantic search across the Kalshi universe.

 > search "bitcoin price" --category crypto --min-volume 10000    Ticker              Title                          Last    Volume
  KXBTC-26APR-B95000  Bitcoin above $95k by Apr 30   $0.58   12,841
  KXBTC-26APR-B100000 Bitcoin above $100k by Apr 30  $0.31    8,203
  KXETH-26APR-B2000   Ethereum above $2k by Apr 30   $0.72    5,419

  3 markets found    02 ### Analyze
 Per-event research report with model probability, drivers, and Kelly sizing.

 > analyze KXBTC-26APR-B95000    Octagon Research Report — KXBTC-26APR-B95000
  ────────────────────────────────────────
  Model Probability   72%
  Market Price        58%
  Edge               +14.0%  (very_high confidence)

  Top Drivers
  1. Bitcoin ETF inflows accelerating       impact: high
  2. Halving cycle momentum                 impact: high
  3. Macro risk-on sentiment            impact: moderate

  Kelly Sizing: 3 contracts YES at $0.58
  Risk gates: ✓ Kelly ✓ Liquidity ✓ Corr ✓ Concentration ✓ Drawdown    03 ### Build a diversified basket
 One call: candidate universe → cluster caps → correlation caps → Kelly sizing.

 > basket build --label fed,cpi,fomc,gdp,jobs -n 5 --max-corr 0.4    Basket built · 5 legs · max pairwise corr 0.32
  ────────────────────────────────────────
  KXFEDDECISION-MAR     YES  $0.61  Kelly $122  cluster: fed-policy
  KXCPIYOY-FEB          NO   $0.44  Kelly $98   cluster: inflation
  KXFOMC-DOTS-25Q4      YES  $0.55  Kelly $87   cluster: fed-policy
  KXU3-MAR              NO   $0.39  Kelly $76   cluster: labor
  KXGDPNOW-Q1           YES  $0.52  Kelly $64   cluster: growth

  Total exposure: $447 · expected return: +18.6%    04 ### Execute
 Confirm with one keystroke. Limit price in cents, side defaults to YES.

 > buy KXBTC-26APR-B95000 3 58    Confirm order? [y/n] y
  ✓ Order placed: BUY 3 YES @ $0.58
  Order ID: abc-123-def

  Cash: $487.26 · Exposure: $1.74 · Open positions: 1        How it connects ## A thin terminal in front of a deep intelligence pipeline.
    You Your terminal Bun runtime · macOS, Linux, WSL  →  CLI kalshi-trading-bot-cli AI agent loop · slash commands  →  Octagon Octagon Research API 21 typed endpoints · model probabilities  →  Exchange Kalshi Order entry · positions · fills    ### Which command hits which endpoint
   search · search edge → /kalshi/markets · /markets-with-edge   similar · peers → /kalshi/markets/similar · /cluster-peers   clusters → /kalshi/clusters · /behavioral-clusters   correlate → /kalshi/markets/correlations   basket build · size · backtest → /kalshi/baskets/* (5 endpoints)   events · analyze → /prediction-markets/events         Setup in 60 seconds ## No clone. No install. Just bunx.
    01 ### Install Bun
 Bun ≥ 1.1 is required — the CLI uses bun:sqlite and runs .tsx directly.

 curl -fsSL https://bun.com/install | bash   02 ### Get a Kalshi API key
 From [kalshi.com](https://kalshi.com) — you'll need an API key plus an RSA private key. Use demo mode for paper trading.

   03 ### Optional: Octagon key
 An [Octagon](https://app.octagonai.co) key unlocks AI edge analysis, semantic search, clusters, and basket construction.

   04 ### Run the CLI
 The setup wizard handles the rest — keys land in ~/.kalshi-bot/.env.

 bunx kalshi-trading-bot-cli@latest         Full command reference Click to expand · 40+ slash commands     ### Discovery

 search [query] | Full-text or semantic search across markets |
 search edge | Rank markets by model edge from Octagon's latest run |
 similar <ticker|"text"> | Semantic neighbors via embeddings |
 clusters [--label X] | Browse thematic K-means clusters |
 clusters --behavioral | Behavioral clusters by 30-day return vectors |
 peers <ticker> | Markets in the same cluster as a ticker |
 events / events <ticker> | Octagon events list + outcome ladder |
 catalysts upcoming --days N | Markets closing in the next N days, grouped by week |

   ### Baskets & portfolio

 correlate <t1> <t2> … | Pairwise Pearson correlation matrix |
 basket build | Diversified basket with cluster + correlation caps |
 basket size | Fractional Kelly sizing for picked legs |
 basket backtest | Total return / Sharpe / max DD on a basket |
 basket validate | Cluster overlap · pairwise corr · calendar clashes |
 themes report | 25-theme dashboard with SEO + liquidity |
 themes audit | Flag dead themes (high SEO, zero volume) |

   ### Trading & account

 analyze <ticker> | Deep analysis: edge, drivers, Kelly sizing |
 watch <ticker> | Live price and orderbook feed |
 buy / sell <ticker> <n> [price] | Place a confirmed order in cents |
 cancel <order_id> | Cancel a resting order |
 portfolio | Positions, P&L, risk snapshot |
 backtest | Model accuracy scorecard + live edge scanner |
 setup / init / clear-cache | Wizard, fresh install, cache reset |

          Install ### Try it now — zero install
 No clone, no setup. The wizard prompts you for keys on first launch and writes them locally to ~/.kalshi-bot/.env.

  $ bunx kalshi-trading-bot-cli@latest    Copy     Build your own ### Or wire the API into your own stack
 Our CLI runs entirely on the public Octagon REST API. 21 typed endpoints — search, clusters, correlations, baskets, edge. Bring your own runtime.

  [Read API docs →](https://octagonai.co/docs/guide/rest-api/prediction-markets-kalshi) [Open Playground ↗](https://app.octagonai.co/playground)

## Attribution Policy

When quoting, summarizing, or reproducing Octagon AI content, attribute it to Octagon AI and link to the Octagon source URL: https://octagonai.co/cli
If a specific page was used, cite that page rather than only the site homepage.
