A real-time insider detection dashboard for Polymarket that identifies suspicious trading patterns using statistical analysis and Z-score calculations.
- Real-time Trade Monitoring: Continuous polling of Polymarket CLOB API for live trade data
- Insider Detection Algorithm: Z-score based analysis to flag trades >3x the wallet's historical average
- Insider Confidence Score: 0-100 rating based on flagged trade percentage, Z-score, and recency
- Bloomberg-Style UI: Professional dark-mode dashboard with live updates
- Trader Profiles: Historical analysis showing baseline vs anomaly bet sizes
- Mock Mode: Development mode with synthetic data for immediate testing
- FastAPI - Modern Python web framework
- SQLAlchemy - Async ORM with SQLite
- Pydantic - Data validation
- NumPy/SciPy - Statistical calculations
- HTTPX - Async HTTP client
- Next.js 15 - React framework with App Router
- Tailwind CSS - Utility-first CSS
- Recharts - Data visualization
- Lucide React - Icon library
- TypeScript - Type safety
polytracker/
├── backend/
│ ├── app/
│ │ ├── api/
│ │ │ └── routes.py # API endpoints
│ │ ├── models/
│ │ │ └── database.py # SQLAlchemy models
│ │ ├── schemas/
│ │ │ └── trader.py # Pydantic schemas
│ │ ├── services/
│ │ │ ├── data_worker.py # Background data ingestion
│ │ │ ├── insider_detector.py # Z-score calculation
│ │ │ └── polymarket_client.py # API client
│ │ └── main.py # FastAPI app
│ ├── requirements.txt
│ ├── .env.example
│ └── run.py
├── frontend/
│ ├── app/
│ │ ├── page.tsx # Main dashboard
│ │ ├── layout.tsx
│ │ └── globals.css
│ ├── components/
│ │ ├── Sidebar.tsx
│ │ ├── StatsBar.tsx
│ │ ├── TradersTable.tsx
│ │ ├── LiveFeed.tsx
│ │ └── TraderDetail.tsx
│ ├── lib/
│ │ ├── api.ts # API client
│ │ ├── types.ts # TypeScript types
│ │ └── utils.ts # Utility functions
│ └── package.json
└── README.md
- Python 3.10 or higher
- Node.js 18 or higher
- npm or yarn
- Navigate to the backend directory:
cd backend- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create environment file:
cp .env.example .env- Configure
.env(optional - defaults work for development):
DATABASE_URL=sqlite+aiosqlite:///./polyedge.db
MOCK_MODE=true
API_HOST=0.0.0.0
API_PORT=8000
POLYMARKET_CLOB_API=https://clob.polymarket.com
POLYMARKET_DATA_API=https://data-api.polymarket.com
POLL_INTERVAL_SECONDS=30
MIN_TRADE_SIZE_USD=5000
Z_SCORE_THRESHOLD=3.0- Run the backend:
python run.pyThe API will be available at http://localhost:8000
- API Docs:
http://localhost:8000/docs - Health Check:
http://localhost:8000/health
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install
# or
yarn install- Run the development server:
npm run dev
# or
yarn dev- Open your browser:
http://localhost:3000
List of flagged wallets with insider confidence scores.
Query Parameters:
min_score(float, default: 0) - Minimum insider score filterlimit(int, default: 50) - Maximum results to return
Response:
[
{
"wallet_address": "0x1234...",
"insider_score": 87.5,
"total_trades": 45,
"avg_bet_size": 2500.0,
"flagged_trades_count": 12,
"last_trade_time": "2026-01-05T10:30:00"
}
]Real-time stream of trades filtered by size or high deviation.
Query Parameters:
min_size(float, default: 5000) - Minimum trade size in USDhours(int, default: 24) - Time window in hourslimit(int, default: 100) - Maximum results
Response:
[
{
"wallet_address": "0x1234...",
"market_name": "Will Bitcoin reach $100k in 2026?",
"trade_size_usd": 25000.0,
"z_score": 4.2,
"timestamp": "2026-01-05T10:30:00",
"deviation_percentage": 320.5
}
]Historical profile for a specific trader.
Response:
{
"wallet_address": "0x1234...",
"total_trades": 45,
"avg_bet_size": 2500.0,
"std_bet_size": 1200.0,
"max_bet_size": 25000.0,
"total_volume": 112500.0,
"insider_score": 87.5,
"last_updated": "2026-01-05T10:30:00",
"flagged_trades_count": 12
}Trade history for a specific trader.
Query Parameters:
limit(int, default: 100) - Maximum trades to return
Dashboard-level statistics.
Response:
{
"total_whales_tracked": 15,
"high_signal_alerts_today": 8,
"total_trades_monitored": 342,
"avg_insider_score": 45.2
}For each trade, we calculate:
z_score = (trade_size - historical_mean) / historical_stdA trade is flagged if |z_score| > 3.0 (configurable)
The score combines three factors:
-
Flagged Trade Percentage (40 points max)
- Proportion of total trades that are flagged
-
Average Z-Score (30 points max)
- Mean z-score of flagged trades
- Normalized: z=3 → 10pts, z=6 → 20pts, z≥9 → 30pts
-
Recency Weight (30 points max)
- Percentage of recent (7 days) trades that are flagged
Mock mode generates realistic synthetic data for development:
- 20 unique wallet addresses
- 5 different markets
- 5 "whale" wallets with occasional large bets (30% chance)
- Random trade sizes: $100-$2,000 (normal), $10,000-$50,000 (whales)
- Realistic timestamps within last 24 hours
Enable in .env:
MOCK_MODE=true- Set
MOCK_MODE=falsein.env - Configure production database (PostgreSQL recommended)
- Use a production ASGI server:
uvicorn app.main:app --host 0.0.0.0 --port 8000 --workers 4- Build the production bundle:
npm run build- Start the production server:
npm startdocker-compose up -d- Backend: Add routes in app/api/routes.py
- Frontend: Create components in components/
- Update types in lib/types.ts
# Backend
cd backend
pytest
# Frontend
cd frontend
npm test- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
MIT License - see LICENSE file for details
- Polymarket for the CLOB and Data APIs
- FastAPI and Next.js communities
- Statistical analysis inspired by financial fraud detection systems
For issues, questions, or contributions:
- Open an issue on GitHub
- Contact: [your-email@example.com]
Built with ❤️ for transparent prediction markets