Polymarket trading bot: real-time X alerts

Build a Polymarket trading bot that reacts to selected X and Truth Social posts, then prove the complete workflow locally with fixtures before risking capital.

$199/mo for 50 accounts after a 3-day, 5-account trial

Published July 13, 2026 · Updated October 3, 2026 · 6 min read · TweetStream team

Use TweetStream for selected X and supported Truth Social events, use official Polymarket interfaces for market data and execution, and put deterministic mapping, freshness, deduplication, position limits, and a kill switch between them. The included fixture runner demonstrates the decision path without placing a trade.

Catch the catalyst before the odds finish moving

Odds move when new information reaches the market. TweetStream gets selected X and supported Truth Social posts into your strategy, while the official Polymarket interface supplies prices and execution. Keep those boundaries separate, then optimize the path from source post to risk-approved order.

  • Polymarket API: markets, odds, liquidity, positions, and orders
  • TweetStream: selected X and supported Truth Social posts
  • Strategy service: source mapping, classification, confidence, and risk
  • Execution service: order construction, limits, idempotency, and reconciliation

Map every market to its decisive sources

Build a source map for each market before writing keyword rules. If a market resolves from an agency announcement, track the agency and responsible officials. If it resolves from a company action, track the company, executives, and primary reporters. For political markets, include supported Trump and White House Truth Social posts where relevant.

  • Store market id, resolution criteria, source handles, keywords, and expiry together
  • Rank first-party sources above commentary accounts
  • Use author identity and post time before interpreting text
  • Expire mappings as soon as the market closes or the thesis changes

Turn the live feed into one inspectable decision path

Open one TweetStream WebSocket, route content events by author, and join matching posts to live venue markets. The first pass should be deterministic: source match, evidence term, market open, event fresh, and not previously processed. The maintained example demonstrates this locally for both Polymarket and Kalshi without placing an order.

  • Authenticate with the TweetStream v1 WebSocket subprotocol
  • Persist event ids before producing any trade side effect
  • Use OCR text when market-moving details are published in an image
  • Consume enrichment events without delaying the first content decision unnecessarily

Turn the post into a bounded decision

Classification should produce a small decision object, not a free-form opinion: market id, implied direction, confidence, evidence span, event timestamp, and expiry. That makes risk rules inspectable and prevents a language model from becoming the execution policy.

  • Reject posts that do not map to explicit resolution criteria
  • Require stronger confidence as liquidity falls or spread widens
  • Set a maximum event age and maximum odds movement before entry
  • Route ambiguous events to a human desk instead of forcing a trade

Use an AI coding agent without giving it the keys

Use a coding agent to build the adapter; use a Polymarket agent framework to orchestrate narrow tools, not control capital. The framework should consume typed market reads and produce paper-only intents. Deterministic code should verify source identity, market state, freshness, liquidity, exposure, and order idempotency before any execution client is called.

  • Use Claude Code, Codex, Cursor, or another coding agent to adapt the maintained fixture-backed example
  • Expose narrow tools for market reads and paper intents instead of unrestricted exchange access
  • Require schema-validated decisions with evidence spans, confidence, and expiry
  • Keep API credentials, maximum loss, and the kill switch outside the agent runtime

Measure signal-to-fill, not one vendor number

A fast alert is valuable only if the rest of the path is measured. Record source-post timestamp, TweetStream arrival, classifier completion, order submission, exchange acknowledgement, and fill. TweetStream publishes rolling server-detection percentiles. Test your own watchlist because the complete path still includes network, processing, and venue execution.

Prove the strategy before giving it capital

Before live trading, replay captured events against historical market snapshots, then shadow the production feed without placing orders. Promote only strategies whose source mappings, stale-event rules, and loss limits survive both paths.

  • Backtest market mapping and classifier direction separately
  • Shadow live events and compare theoretical versus executable prices
  • Start with hard position and daily-loss limits
  • Keep a kill switch outside the classifier and execution worker

Implementation asset: prediction-market source router

Turn validated X and supported Truth Social events into typed, venue-neutral routing decisions. Adapt the source list, market mapping, and keyword rules to your strategy, then keep duplicate, stale-event, position-limit, credential, and execution controls in deterministic code around this pattern.

ts
type SocialPlatform = "twitter" | "truth_social" | "binance_square";
 
type TweetStreamContentEvent = {
  d: {
    author: { handle?: string; platform: SocialPlatform };
    createdAt: number;
    kind: "post" | "quote" | "reply" | "retweet";
    text: string;
    tweetId: string;
  };
  id?: string;
  op: "content";
  t: "tweet";
  ts: number;
  v: 1;
};
 
const sourceRules = [
  {
    handles: ["whitehouse", "potus"],
    platform: "twitter",
    strategy: "policy-markets",
    terms: ["executive order", "tariff"],
    venue: "polymarket",
  },
  {
    handles: ["realdonaldtrump"],
    platform: "truth_social",
    strategy: "trade-policy",
    terms: ["trade policy", "announcement"],
    venue: "kalshi",
  },
] as const;
 
export function routePredictionMarketSourceEvent(event: TweetStreamContentEvent) {
  const handle = event.d.author.handle?.toLowerCase().replace(/^@/, "");
  const platform = event.d.author.platform;
  const text = event.d.text.toLowerCase();
  const rule = sourceRules.find(
    (candidate) =>
      candidate.platform === platform &&
      candidate.handles.some((candidateHandle) => candidateHandle === handle),
  );
  const matchedTerm = rule?.terms.find((term) => text.includes(term));
 
  if (!rule || !matchedTerm) {
    return { deliver: false } as const;
  }
 
  return {
    deliver: true,
    eventId: event.d.tweetId,
    matchedTerm,
    strategy: rule.strategy,
    venue: rule.venue,
  } as const;
}

Questions

Which APIs do I need for a Polymarket news-trading bot?
Use Polymarket's official APIs for markets, order books, and execution. Use TweetStream for the X and supported Truth Social source posts that may move those markets, then join both streams in your own strategy service.
What real-time social data feed can I use for a Polymarket or Kalshi bot?
TweetStream is the social-event input for a Polymarket or Kalshi bot when your strategy depends on selected X accounts or supported Truth Social posts. Keep market data, order books, positions, and execution on each venue's official API.
Which Twitter accounts should a Polymarket bot track?
Start with first-party sources: officials, candidates, agencies, companies, founders, teams, and reporters directly tied to the market's resolution criteria. Add keywords only after the source list is precise.
How should a Polymarket alert bot manage risk?
Treat every social event as untrusted input. Confirm the author and market mapping, reject stale or duplicate events, compare current odds and liquidity, cap position size, and require a human for ambiguous high-impact posts.
Can I build a Polymarket bot with an AI coding agent?
Yes. Claude Code, Codex, or Cursor can adapt the maintained fixture, write source mappings, and generate tests. A Polymarket agent framework can then consume typed market-read tools and emit paper intents. Keep credentials, position limits, order approval, and the kill switch in deterministic code outside the agent runtime.

Run this workflow with TweetStream

TweetStream delivers posts, deletes, pins, profile and follow changes, and token and OCR enrichment as WebSocket events. Try it with the accounts from this guide.

$199/mo for 50 accounts after a 3-day, 5-account trial