An autonomous AI trading agent for Polymarket that identifies market inefficiencies, calculates optimal bet sizes, and executes trades automatically. This system leverages ChatGPT's predictive capabilities against existing market odds to find profitable edges.
- Python 3.8+ installed
- A Polygon network wallet with MATIC (for gas) and USDC (for trading)
- API keys for OpenAI and SerpAPI
- Basic understanding of prediction markets and crypto wallets
- Clone this repository
git clone https://github.com/yourusername/PolyTrader.git
cd PolyTrader
- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Set up environment variables
cp .env.example .env
# Edit .env with your API keys and configuration
- Run the application
python app.py
- Visit http://127.0.0.1:5000 in your browser
- Market Analysis: Continuously scans Polymarket for opportunities
- AI-Powered Predictions: Uses ChatGPT to analyze various events
- Edge Detection: Compares AI predictions with market consensus to find inefficiencies
- Intelligent Bet Sizing: Implements Kelly Criterion for optimal bankroll management
- Automated Execution: Places trades via Polymarket Agents SDK
- Risk Management: Includes safety features to protect your bankroll
The system consists of three core modules:
-
Analysis Module
- Uses ChatGPT to analyze upcoming events
- Compares predictions with current Polymarket odds
- Identifies opportunities with significant edge
-
Decision Module
- Evaluates opportunities based on edge percentage
- Calculates optimal bet size using Kelly Criterion
- Manages risk to preserve bankroll
-
Execution Module
- Connects to Polymarket using their official Agents SDK
- Places trades automatically with verification
- Implements safety measures and error handling
Edit your .env
file with the following variables:
# OpenAI API key (required for AI functionality)
OPENAI_API_KEY=your_openai_api_key_here
# Flask app settings
FLASK_SECRET_KEY=your_flask_secret_key_here
# SerpAPI key (required for market data)
SERPAPI_API_KEY=your_serpapi_api_key_here
# Polymarket API credentials
POLYMARKET_API_KEY=your_polymarket_api_key_here
# Wallet information (required for transactions)
POLYGON_WALLET_PRIVATE_KEY=your_private_key_here
POLYMARKET_WALLET_ADDRESS=your_wallet_address_here
# Trading settings
INITIAL_BANKROLL=1000
MAX_BET_PERCENTAGE=0.05
MIN_EDGE_PERCENTAGE=0.15
⚠️ IMPORTANT: Never commit your.env
file or hardcode API keys in the source code. The.env
file is included in.gitignore
to prevent accidental exposure of your credentials.
Start the web interface:
python app.py
Run in simulation mode (no real trades):
python app.py --simulation
Analyze specific markets:
python polymarket_ai_search.py --query "NBA games tonight"
Trading involves substantial risk and is not suitable for all investors. Past performance is not indicative of future results. Start with small amounts to test the system before scaling up. Implement proper risk management.
app.py
- Main entry point for the Flask applicationpolymarket_ai_search.py
- Search and analysis of Polymarket eventsplace_polymarket_bet.py
- Automated bet executionfetch_current_markets.py
- Real-time market data retrieval
This project is licensed under the MIT License - see the LICENSE file for details.
Siraj Raval
- OpenAI for ChatGPT API
- Polymarket team for the Agents SDK
- All contributors and testers
⭐ Star this repo if you find it useful! Join our Discord community to discuss improvements and share results.
Note: This system is for educational purposes. Always do your own research before trading.