← Back to Blog

2026-03-05 · 2 min read

Polymarket Sentiment Agent: Let the LLM Read, Let the Math Decide

A prediction-market agent where the LLM labels news sentiment and Python computes a Bayesian posterior. Edge is the gap between that posterior and the market price. FastAPI backend, React client, paper trading.

PythonBayesianFastAPIReact

The core design principle

LLMs read language well and price probability badly. So the agent draws a hard line: the LLM only parses headlines into a sentiment label, never a price. A deterministic Python layer turns that label into a Bayesian posterior, and the signal is the gap between the posterior and the market-implied prior.

The separation is deliberate. Uncalibrated LLM price guesses are unreliable; calibrated Bayesian math is auditable and reproducible.

How a signal is formed

Headline
  → LLM labels sentiment
  → Bayesian update produces posterior probability
  → Edge = posterior − market-implied price
  → surface as a paper trade

Every number that touches a trade comes from the math layer, not the model. The LLM's output stays confined to what it's reliable at: reading tone and stance from text.

Serving it

A FastAPI backend exposes a status endpoint and the sentiment/posterior pipeline; a React front end inspects current signals. It runs in paper-trading mode because the goal is to test whether the Bayesian edge is real, not to move capital.

Why Bayesian, not a classifier

A posterior carries its own uncertainty. Instead of a point prediction, the agent reasons about how far a piece of news should move a belief relative to where the market already sits. When posterior and price agree, there's no edge and no trade, which is what you want from a signal generator.

Takeaway

The interesting engineering is boundary-drawing: give the LLM the narrow, language-shaped job it excels at and hand every probabilistic decision to explicit, testable math. Paper trading keeps the claims in check while the design gets validated.

Related project

Polymarket Sentiment Agent

Prediction-market agent where the LLM only labels headline sentiment and Python computes the Bayesian edge versus market price. Paper trading, live demo.