Real-time Bitcoin price comparison showing which data source reflects price changes first: Binance Trade, Binance Aggregated Trades, or Polymarket's Chainlink oracle feed.
Analyze price discovery and latency by comparing:
- Binance Individual Trades - Granular trade-by-trade data
- Binance Aggregated Trades - Combined trades for charting
- Chainlink Oracle (via Polymarket) - Decentralized price feed
All WebSocket connections are handled server-side via Next.js API routes:
/api/binance-trade- Connects to Binance trade stream/api/binance-agg- Connects to Binance aggregated trade stream/api/chainlink- Connects to Polymarket's Chainlink feed
The server streams price data to the client using SSE, which:
- ✅ Provides accurate server-side timestamps
- ✅ Enables deployment close to exchange servers for minimal latency
- ✅ Measures true network latency (server→client)
- ✅ Auto-reconnects on connection loss
- Accurate Latency Measurements - Server timestamps eliminate client-side delays
- Geographic Optimization - Deploy near exchanges (e.g., AWS Singapore for Binance)
- Lower Infrastructure Load - Server manages persistent WebSocket connections
- Better Reliability - Server-side reconnection logic
npm installnpm run devnpm run build
npm startThis project is fully compatible with Coolify and Nixpacks. See DEPLOYMENT.md for detailed instructions.
Quick Deploy:
- Connect your Coolify instance to this GitHub repository
- Coolify auto-detects Next.js and uses the included
nixpacks.toml - Deploy! No additional configuration needed.
The project includes:
- ✅
nixpacks.tomlfor automated build configuration - ✅ Standalone Next.js output for optimal container performance
- ✅ Dynamic port binding for Coolify compatibility
- ✅ Automatic WebSocket connection management
- 🔵 Binance Trade - Every individual trade
- 🔷 Binance Agg - Aggregated trades
- 🟢 Chainlink - Oracle-aggregated price
- ⚡ Highlights which source changes price first
- 📈 Tracks significant price movements (>0.01%)
- ⏱️ Shows millisecond-level timing differences
- Server→Client latency displayed for each feed
- Real-time connection status indicators
- Auto-reconnection on disconnects
- Overlapping price charts for direct comparison
- Color-coded price sources
- Interactive tooltips with precise values
-
Binance - Deploy in Singapore region
- Binance servers are primarily in Singapore
- AWS:
ap-southeast-1 - Vercel: Singapore region
-
Polymarket/Chainlink - Deploy in US East
- Polymarket websocket:
wss://ws-live-data.polymarket.com - AWS:
us-east-1 - Vercel: Washington D.C region
- Polymarket websocket:
- Vercel - Easy deployment with geographic edge functions
- AWS ECS/Lambda - Full control over server location
- Railway - Simple deployment with region selection
This tool helps answer:
- Which exchange/oracle updates prices first?
- How much latency exists between sources?
- Are aggregated trades faster than individual trades?
- How does Chainlink oracle lag compare to spot exchanges?
- Next.js 14 - React framework with API routes
- TypeScript - Type safety
- Tailwind CSS - Styling
- Recharts - Data visualization
- ws - Server-side WebSocket library
- Server-Sent Events - Real-time data streaming
Streams Binance individual trades via SSE
data: {"type":"price","source":"binance_trade","price":92589.50,"serverTimestamp":1700000000000}
Streams Binance aggregated trades via SSE
data: {"type":"price","source":"binance_agg","price":92589.51,"serverTimestamp":1700000000000}
Streams Polymarket Chainlink BTC/USD prices via SSE
data: {"type":"price","source":"chainlink","price":92589.45,"serverTimestamp":1700000000000}
The server automatically:
- Reconnects on disconnection
- Sends PING/PONG for Polymarket keepalive
- Filters significant price changes
- Manages multiple concurrent client connections
MIT
Contributions welcome! This is a research tool for understanding cryptocurrency price discovery mechanisms.