A serverless application that monitors Polymarket prediction markets, detects significant price changes, and posts updates to Twitter.
Polymarket Watcher continuously monitors prediction markets on Polymarket, identifies markets with significant price changes, and posts updates about these changes to Twitter. It's designed to run as a set of AWS Lambda functions that execute on a schedule.
- Market Monitoring: Fetches data from the Polymarket API and stores it in DynamoDB
- Price Change Detection: Analyzes market data to detect significant price changes
- Multi-outcome Support: Handles both binary (Yes/No) and multi-outcome markets
- Volatility Thresholds: Adjusts significance thresholds based on market liquidity
- Rate Limiting: Controls post frequency to avoid spamming
- Market Categorization: Categorizes markets by topic (Politics, Crypto, Tech, etc.)
- Historical Data: Maintains historical price data for trend analysis
- Signal Detection: Advanced signal detection with adaptive thresholds
- Resolution Tracking: Tracks market resolutions to evaluate signal accuracy
- Confidence Scoring: Assigns confidence scores to detected signals
- Feedback Loop: Uses resolution data to improve signal detection over time
The application consists of five main Lambda functions:
- Collector: Fetches market data from Polymarket API and stores it in DynamoDB
- Analyzer: Analyzes market data to detect significant price changes
- Signal Analyzer: Detects more sophisticated market signals using adaptive thresholds
- Resolution Tracker: Tracks market resolutions and evaluates signal accuracy
- Publisher: Posts updates about significant price changes to Twitter with confidence indicators
- The Collector Lambda runs every 20 minutes to fetch market data from Polymarket
- Market data is stored in the
marketsDynamoDB table - Historical price points are stored in the
historicalDynamoDB table - The Analyzer Lambda runs after the Collector to detect significant price changes
- The Signal Analyzer Lambda runs every 15 minutes to detect more sophisticated signals
- Detected signals are stored in the
signalsDynamoDB table - The Resolution Tracker Lambda runs every 60 minutes to track market resolutions
- Resolution data is stored in the
resolutionsDynamoDB table and used to update thresholds - When significant changes are detected, the Publisher Lambda is triggered
- The Publisher posts updates to Twitter with confidence indicators and records the posts in the
postsDynamoDB table
Configuration settings are stored in serverless/common/config.py:
- API URLs
- DynamoDB table names
- Twitter API credentials
- Market fetching parameters
- Volatility thresholds
- Signal types and strengths
- Confidence score weights
- Post rate limiting
- Categories of interest
The following environment variables are required:
TWITTER_API_KEY: Twitter API keyTWITTER_API_SECRET: Twitter API secretTWITTER_ACCESS_TOKEN: Twitter access tokenTWITTER_ACCESS_SECRET: Twitter access token secretAWS_ACCESS_KEY_ID: AWS access key IDAWS_SECRET_ACCESS_KEY: AWS secret access keyAWS_REGION: AWS region
- Python 3.8+
- AWS account
- Twitter Developer account
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Configure environment variables
- Deploy to AWS using the Serverless Framework:
serverless deploy
You can test the Lambda functions locally:
python serverless/collector/collector.py
python serverless/analyzer/analyzer.py
python serverless/signal_analyzer/signal_analyzer.py
python serverless/resolution_tracker/resolution_tracker.py
python serverless/publisher/publisher.pyMIT