by Mist-kail
Polymarket trading ai bot: polymarket trading bot, Polymarket trading bot || polymarket trading bot, Polymarket ai agent bot || polymarket trading bot, Polymarket trading bot || polymarket trading bot, Polymarket trading bot || polymarket trading ai, Polymarket trading bot || polymarket ai agent
# Add to your Claude Code skills
git clone https://github.com/Mist-kail/PolyMarket-trading-AI-model[![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] [![Issues][issues-shield]][issues-url] [![MIT License][license-shield]][license-url]
🤖 AI-powered autonomous trading agents for Polymarket prediction markets
Polymarket Agents is a modern, open-source framework for building sophisticated AI trading agents on Polymarket. Leverage state-of-the-art LLMs, RAG (Retrieval-Augmented Generation), and superforecasting methodologies to create intelligent trading systems that analyze markets, events, and news to make informed predictions.
Built with Python 3.12+ | MIT Licensed | Production Ready
This code is free and publicly available under MIT License open source license (terms of service)!
No comments yet. Be the first to share your thoughts!
This project requires Python 3.12+.
Clone the repository
git clone https://github.com/Mist-Kail/PolyMarket-AI-agent-trading.git
cd poly-ai-trading-agent
Create a virtual environment
Using venv (recommended):
python -m venv .venv
Or using uv (faster):
uv venv
Activate the virtual environment
.venv\Scripts\Activate.ps1
.venv\Scripts\activate.bat
source .venv/bin/activate
Install the project
Using pip:
pip install -e .
With BlockRun x402 support (recommended):
pip install -e ".[blockrun]"
Or with development dependencies:
pip install -e ".[dev]"
Using uv (faster):
uv pip install -e ".[blockrun,dev]"
Set up environment variables
Create a .env file in the project root:
# Copy example if available, or create new
touch .env
Add the following environment variables:
# Required for trading (Polygon USDC)
POLYGON_WALLET_PRIVATE_KEY="your_private_key_here"
# LLM API - Choose ONE option:
# Option 1: BlockRun x402 pay-per-request (recommended)
# No API key management, pay only for what you use via USDC on Base
BLOCKRUN_WALLET_KEY="your_base_wallet_private_key_here"
# Option 2: Direct OpenAI API
OPENAI_API_KEY="your_openai_api_key_here"
# Required for MongoDB (running history storage)
MONGODB_URI="mongodb://localhost:27017/"
MONGODB_DATABASE="polymarket_agent"
# Optional - for news integration
NEWSAPI_API_KEY="your_newsapi_key_here"
# Optional - for web search
TAVILY_API_KEY="your_tavily_key_here"
Important Notes:
.env file to version controlSet up MongoDB (for running history)
MongoDB is used to store all running history including:
Option A: Local MongoDB
Install MongoDB locally:
brew install mongodb-communitysudo apt-get install mongodb or follow MongoDB installation guideStart MongoDB:
# Windows
mongod
# macOS/Linux
sudo systemctl start mongod
# or
mongod
Option B: MongoDB Atlas (Cloud)
For cloud-hosted MongoDB:
MONGODB_URI in your .env file:
MONGODB_URI="mongodb+srv://username:password@cluster.mongodb.net/"
Note: If MongoDB is not configured or unavailable, the application will continue to work normally, but running history will not be saved.
Load your wallet with USDC (if trading)
Before executing trades, ensure your Polygon wallet has sufficient USDC balance for trading.
The CLI is the primary interface for interacting with Polymarket. All commands follow this format:
python -m scripts.python.cli <command-name> [options]
To see all available commands:
python -m scripts.python.cli --help
To get help for a specific command:
python -m scripts.python.cli <command-name> --help
Retrieve and display markets from Polymarket.
Command:
python -m scripts.python.cli get-all-markets [--limit LIMIT] [--sort-by SORT_BY]
Parameters:
--limit (optional): Number of markets to retrieve (default: 5)--sort-by (optional): Sorting criterion (default: "spread")Examples:
# Get 10 markets sorted by spread
python -m scripts.python.cli get-all-markets --limit 10 --sort-by spread
# Get 5 markets (default)
python -m scripts.python.cli get-all-markets
# Get 20 markets
python -m scripts.python.cli get-all-markets --limit 20
Output: Displays a list of markets with details including:
Get trending markets sorted by 24-hour volume. This is useful for finding the most active markets.
Command:
python -m scripts.python.cli get-trending-markets [--limit LIMIT]
Parameters:
--limit (optional): Number of trending markets to retrieve (default: 10)Examples:
# Get top 10 trending markets
python -m scripts.python.cli get-trending-markets
# Get top 25 trending markets
python -m scripts.python.cli get-trending-markets --limit 25
# Get top 5 trending markets
python -m scripts.python.cli get-trending-markets --limit 5
Output: Displays trending markets sorted by 24-hour volume, showing the most active markets first.
Retrieve and display events from Polymarket.
Command:
python -m scripts.python.cli get-all-events [--limit LIMIT] [--sort-by SORT_BY]
Parameters:
--limit (optional): Number of events to retrieve (default: 5)--sort-by (optional): Sorting criterion (default: "number_of_markets")Examples:
# Get 10 events sorted by number of markets
python -m scripts.python.cli get-all-events --limit 10 --sort-by number_of_markets
# Get 5 events (default)
python -m scripts.python.cli get-all-events
Output: Displays events with details including:
Search for news articles related to specific keywords. Requires NewsAPI key.
Command:
python -m scripts.python.cli get-relevant-news <keywords>
Parameters:
keywords (required): Comma-separated keywords to search forExamples:
# Search for news about Bitcoin
python -m scripts.python.cli get-relevant-news "Bitcoin,crypto"
# Search for news about elections
python -m scripts.python.cli get-relevant-news "election,president"
# Search for multiple keywords
python -m scripts.python.cli get-relevant-news "AI,technology,machine learning"
Output: Displays news articles with: