DEV Community

lweiss01
lweiss01

Posted on

I Built a Prediction Market Insider Trading Detector in One Afternoon (Because George Santos)

This morning I woke up to news that George Santos is under federal investigation for insider trading on Kalshi. Within a few hours, I had a working anomaly detector monitoring 410 politically-sensitive prediction markets with a live dashboard.

Here's how it happened, what I found, and how you can run it yourself.


What Santos Actually Did

The short version is almost embarrassingly simple. The day before Trump's State of the Union address, Santos posted a video on X saying he'd be in the gallery. Traders on Kalshi piled into "yes he'll attend" contracts and the odds shot up.

What Santos didn't mention was that he'd already placed bets that he wouldn't attend. When he posted "Watching SOTU from an airport tv was not part of the plan! FML" while Trump was speaking, those odds cratered and Santos walked away with tens of thousands of dollars.

Kalshi caught it because they have internal account data. They knew which account placed those trades. They froze it, referred the matter to the DOJ and the CFTC, and here we are.

The thing that stuck with me reading the story was a simpler question: what could you see from the outside?


The Public API Question

Kalshi has a solid public REST API. No auth required for market data. I'd poked at it before for other projects, so I knew the shape of it. The question was whether the historical trade data was rich enough to detect the Santos pattern after the fact.

The Santos pattern, stripped down, is:

  1. Someone with private knowledge establishes a position
  2. A public statement moves the market significantly
  3. Their position was already on the right side of that move

You can't see who placed trades from the public API. But you can see that unusual volume concentration happened before a market moved. That's the tipping-point signal -- not proof of anything, but a flag worth examining.

So I started pulling on the thread.


What I Found in the API

After some exploration (the historical endpoint pagination is a bit of an adventure), I found that Kalshi's public API exposes:

  • Full trade history per market -- ticker, price, contract size, timestamp, block trade flag
  • Candlestick data at 1-minute, 1-hour, and 1-day intervals
  • Market metadata including series, category, open/close time, volume

What it doesn't expose: user identity, order placement timestamps (only fill time), or anything that would let you name a specific trader.

The Santos SOTU markets themselves turned out to be inaccessible -- they were structured as multivariate markets with a different ticker format that doesn't surface cleanly through the standard search. But that's fine. The Santos case is the argument for why this tool should exist, not the data it runs on.

What I found instead was more interesting.


The Watchlist

I spent about an hour mapping out which Kalshi series carry genuine MNPI risk -- markets where someone with access to non-public government information would have a meaningful trading edge.

The list got long fast:

Executive Actions -- Cabinet departures (KXCABOUT), next AG (KXNEXTAG), next SecDef, next DNI, pardons, insurrection act invocation, martial law. Anyone in the White House personnel office or inner circle knows these things before markets do.

SCOTUS -- resignation markets, court size change, next justice confirmation. Clerks and justices themselves know when a retirement is coming.

Economic Data -- Fed rate decisions, CPI, GDP. BLS and BEA staff have the data weeks before release.

Geopolitical -- Greenland acquisition, Panama Canal, Taiwan recognition, Zelensky-Putin talks. NSC and State Department staff work these negotiations in real time.

Congressional -- impeachment, house/senate control, government shutdown, veto override. Congressional whips know vote counts before anyone else.

That's 33 series, 410 open markets, and a combined trade history of over 123,000 records from just the first collection run.


The Anomaly Scorer

With data flowing in, I built a three-signal scorer:

Volume Z-Score -- compares recent trade volume against a rolling baseline. A spike of 8+ standard deviations above normal is a strong signal. This is the Santos pattern in statistical form: someone piling into a position before a market-moving event.

Block Trade Ratio -- the API flags block trades (large privately-negotiated contracts) separately. Heavy block trade concentration on a political market before an announcement is suspicious in a way that retail chatter isn't.

Price Divergence -- detects sudden directional price movement inconsistent with gradual drift. The signature of a market that already knows something.

The compound score combines all three with a block trade modifier. Thresholds: yellow at 25, red at 60.


What Flagged on Day One

pmwatch dasbhoard showing market signals

Four markets scored above threshold within hours of the first collection run:

Market Score What it is
KXNEXTAG-29-TBLA 167 Todd Blanche for AG, 22% price move
KXNEXTODNI-29-RCRA 156 Rick Crawford for DNI, 129% price move
KXGREENTERRITORY-29 152 US acquires Greenland, vol z=11.6
KXCPI-26MAY-T0.5 105 CPI above 0.5%, moving DOWN one week before June 10 release

To be clear: high scores don't mean insider trading happened. They mean unusual market activity that warrants a closer look.

TBLA is Todd Blanche -- Trump's former personal attorney who represented him through the criminal trials. RCRA is Rick Crawford, the Arkansas congressman who has been floated for intelligence roles. Both markets were flagging compound anomalies with volume z-scores above 8 on pmwatch's first run.

The Todd Blanche signal is worth noting specifically. It strengthened from 118 to 167 between the first and second hourly collection runs, which is the pattern you'd expect from a position being built ahead of an announcement rather than random noise. And the CPI market moving down with unusual volume a week before BLS publishes the May number? That's a flag worth watching.

I don't know what any of this means. That's kind of the point. pmwatch surfaces candidates. Investigators with subpoena power figure out the rest.


The Stack

Nothing exotic here:

  • Python for the collector and scorer
  • SQLite for storage (plenty for this use case)
  • APScheduler to run collection every 60 minutes
  • FastAPI for the API layer
  • Plain HTML + JS for the dashboard -- no build step, deploys anywhere

The entire thing runs on the public Kalshi API with no authentication. Setup is three commands:

git clone https://github.com/lweiss01/pmwatch.git
cd pmwatch
pip install -r requirements.txt
python scheduler.py
uvicorn api:app --port 8000
Enter fullscreen mode Exit fullscreen mode

What This Can and Can't Do

Can detect: unusual volume concentration before events, block trade anomalies, price divergence inconsistent with public information flow.

Can't do: identify specific traders, prove intent, access order placement timestamps (only fill time is public), or monitor Polymarket (offshore, separate API).

This is a tipping-point detector. It finds markets that look wrong. Kalshi and the CFTC have the identity layer to take it further.


Why It Matters Right Now

The CFTC issued an advisory on prediction market insider trading in February 2026. H.R. 7004, the Public Integrity in Financial Prediction Markets Act, was introduced in January after a trader made $400,000 on the Polymarket Maduro capture market right before the US military operation. The Senate passed a resolution in April preventing its own members from using prediction markets.

The regulatory infrastructure is being built right now. Public monitoring tools that work from open data are part of that ecosystem -- the same role that STOCK Act trackers like Quiver Quantitative play for congressional stock trading, but for the prediction market era.

GovGreed tracks 190,000 congressional stock trades and scores them with a 7-layer AI model. Nobody is doing that for prediction markets yet.

pmwatch is a start.


What's Next

The immediate roadmap:

  • Social media correlation -- cross-reference X post timestamps with trade anomaly windows
  • Government calendar integration -- BLS release schedule, FOMC blackout periods
  • Polymarket support
  • Webhook alerts for high-score signals

The repo is at https://github.com/lweiss01/pmwatch. Issues and PRs welcome. If you work in fintech, policy, or prediction markets and want to talk about where this goes, I'm easy to find.


Built June 3, 2026. The same day the Santos story broke. Sometimes timing is everything.

Top comments (0)