Project
Polymarket Insider
Watches every large trade on Polymarket and flags the statistically unusual ones a few minutes after they happen.
What it does
- Polls Polymarket's public trades API every 60 seconds for every trade of $500 or more, and backfills about six hours of history on startup.
- Keeps running statistics per wallet and scores each trade from 0 to 100: a large first trade, a size spike far above the wallet's usual bets, and an Isolation Forest.
- Flags a trade at 60 or more, so a rule and the model have to agree, and sends it to a Discord webhook and a small FastAPI endpoint.
How it works
An asyncio feed asks the API only for large trades, so consecutive pages overlap and nothing slips through its five-minute cache. Each wallet's mean and variance are updated with Welford's online algorithm, and every trade gets a z-score against the wallet's previous average. Two rules and an unsupervised Isolation Forest, retrained every hour on the latest 50,000 trades, add up the score.
The honest bit
A flag means "statistically unusual", not insider trading: nobody publishes confirmed insider trades, so precision and recall cannot be measured. The one recorded run lasted 26 minutes and flagged nothing; its top scores were all sports bets, most of them near-certain, which is the obvious next filter. The thresholds are judgement calls, not tuned values.
- Python
- asyncio
- httpx
- scikit-learn
- SQLAlchemy
- SQLite / PostgreSQL
- FastAPI