Advanced real-time financial intelligence platform integrating Polygon.io WebSocket for live stock data with Telegram Bot API for command and control operations. Designed with intelligence agency aesthetics and professional-grade monitoring capabilities.
- Live Data Stream: Polygon.io WebSocket integration for real-time stock trades
- Multi-Symbol Tracking: Monitor multiple stocks simultaneously (AAPL, MSFT, GOOGL, etc.)
- Anomaly Detection: Automatic detection of volume spikes and price movements
- Intelligence Reports: Military-style console logging and reporting
- Command Interface: Full bot command system for remote monitoring
- Multi-Agent Support: Multiple Telegram users can connect simultaneously
- Real-time Alerts: Automatic notifications for anomalous trading activity
- Status Reporting: Comprehensive system status and portfolio reports
- Live Intelligence Feed: Real-time web interface with agency styling
- System Monitoring: Connection status, uptime, and trade statistics
- Dark Theme: Professional intelligence agency aesthetic
- Auto-refresh: Live updates every 5 seconds
- Node.js 16+ installed
- Polygon.io API key (provided:
UWxatfnpZfpPMIrFhcmU3rjC1OOYSIqU) - Telegram Bot Token (configured: existing @frbrssbot)
# Install dependencies
npm install @polygon.io/client-js node-telegram-bot-api dotenv ws express
# Copy environment configuration
cp .env.example .env
# Run the XRZ Intelligence System
node xrz-intelligence.jsEdit .env file:
POLYGON_API_KEY=UWxatfnpZfpPMIrFhcmU3rjC1OOYSIqU
TELEGRAM_TOKEN=7988577153:AAGpgt3Rjuu3-1bnlHXdeHiwJQd4DiAhEg0
TELEGRAM_CHAT_ID=6598842264
PORT=3000/start- Initialize agent connection and view welcome message/help- Display complete command reference/status- Get comprehensive system status report
/monitor AAPL- Start tracking Apple stock for anomalies/monitor MSFT- Start tracking Microsoft stock/unmonitor AAPL- Stop tracking Apple stock/portfolio- View all currently monitored stocks with latest prices
/alerts- View recent anomalous trading activity/status- Detailed system health and statistics
- AAPL - Apple Inc.
- MSFT - Microsoft Corporation
- GOOGL - Alphabet Inc.
- TSLA - Tesla Inc.
- AMZN - Amazon.com Inc.
- NVDA - NVIDIA Corporation
- META - Meta Platforms Inc.
Access the intelligence dashboard at: http://localhost:3000
- System Status: Connection state, uptime, trade statistics
- Active Monitors: Currently tracked stocks and agent count
- Anomaly Detection: Alert counts and last update timestamps
- Live Feed: Real-time trade data stream with timestamps
- Auto-refresh: Updates every 5 seconds
- Triggers when trade volume exceeds 5x average volume
- Alert Type:
VOLUME_SPIKE - Severity:
HIGH - Example: "π¨ VOLUME ANOMALY: AAPL traded 150,000 shares (7x normal volume)"
- Triggers on price changes exceeding 2% from recent average
- Alert Type:
PRICE_MOVEMENT - Severity:
MEDIUM - Example: "π PRICE ALERT: MSFT at $285.50 (2.45% change)"
- WebSocket Client: Polygon.io connection with auto-reconnection
- Telegram Bot: Command processing and alert broadcasting
- Web Server: Express.js dashboard with real-time updates
- Intelligence Engine: Anomaly detection and analysis
- State Management: In-memory tracking of trades and alerts
- Auto-reconnection: Up to 10 attempts with exponential backoff
- Graceful Degradation: System continues operating during temporary disconnections
- Error Logging: Comprehensive error tracking and reporting
- Recovery Protocols: Automatic subscription restoration after reconnection
node xrz-intelligence.jsAgent: /start
Bot: π― XRZ Intelligence Agency Welcome...
Agent: /monitor AAPL
Bot: π‘ [XRZ-MONITOR] Now tracking AAPL for intelligence gathering
Agent: /status
Bot: π XRZ Intelligence System Status
π Connection: CONNECTED
β±οΈ Uptime: 2h 15m
π Total Trades: 1,847
π [XRZ-INIT] Initializing XRZ Intelligence Agency Financial Monitor...
β
[XRZ-CONNECTED] WebSocket established with Polygon.io Intelligence Network
π‘ [XRZ-MONITOR] Now tracking AAPL for anomalous trading activity
π [XRZ-INTEL] AAPL: $175.23 | Volume: 1,250 | 14:32:15
π¨ [XRZ-ALERT] VOLUME ANOMALY: AAPL traded 45,000 shares (6x normal volume)
- @polygon.io/client-js: WebSocket client for Polygon.io API
- node-telegram-bot-api: Telegram Bot API integration
- express: Web server for dashboard interface
- dotenv: Environment variable management
- ws: WebSocket protocol support
- Real-time Processing: Sub-second trade data processing
- Memory Efficient: Circular buffer for trade history (100 trades max)
- Scalable: Supports unlimited Telegram agents
- Robust: Auto-recovery from network failures
- API Key Protection: Environment variable configuration
- Access Control: Telegram bot token authentication
- Data Sanitization: Input validation and error handling
- Secure Communications: HTTPS/WSS protocol usage
β [XRZ-ERROR] WebSocket error: Connection refused
Solution: Verify Polygon.io API key and network connectivity
β [XRZ-TELEGRAM] Failed to send to chat: 401 Unauthorized
Solution: Verify bot token and ensure bot is added to target chats
π‘ [XRZ-MONITOR] Now tracking AAPL for anomalous trading activity
Solution: Ensure markets are open and symbol is valid
Enable verbose logging by setting:
NODE_ENV=development- Upload all files to Replit project
- Configure environment variables in Replit Secrets
- Use "Run" button or configure custom run command:
node xrz-intelligence.js - Access web interface via Replit's provided URL
# Install PM2 for process management
npm install -g pm2
# Start with PM2
pm2 start xrz-intelligence.js --name "xrz-intelligence"
# Monitor
pm2 status
pm2 logs xrz-intelligence- GET /api/status: System status JSON
{ "connectionStatus": "CONNECTED", "totalTrades": 1847, "uptime": 8100, "lastUpdate": "2025-08-18T07:15:30.000Z", "activeSymbols": ["AAPL", "MSFT", "GOOGL"], "telegramChats": 3, "anomalies": 12 }
This project is for educational and research purposes. Ensure compliance with Polygon.io terms of service and Telegram Bot API guidelines.
For technical issues or feature requests, contact the development team or refer to the official documentation: