An AI-driven automated trading bot for Polymarket prediction markets, using Gemini Deep Research or Claude Research to identify mispriced low-probability events and sentiment-driven price swings.
READ CAREFULLY BEFORE USING THIS SOFTWARE.
This project is released for educational and research purposes only. It is NOT financial advice and NOT intended for production trading with real funds.
Risk Warnings:
- 🔴 Cryptocurrency and prediction market trading involves substantial risk of loss. You can lose all of your invested capital.
- 🔴 Automated trading amplifies risk. Bugs, API failures, AI misjudgments, or network issues may cause unexpected losses.
- 🔴 Polymarket access is restricted in some jurisdictions. Users are responsible for compliance with their local laws.
- 🔴 This bot uses AI-generated trading decisions. AI models can be wrong, biased, or hallucinate. Do not trust them blindly.
- 🔴 No warranty. The software is provided "AS IS" without warranty of any kind. The author(s) accept NO responsibility for any losses, damages, or legal issues arising from its use.
If you choose to use this code with real funds, you do so entirely at your own risk. We strongly recommend starting with paper trading and tiny position sizes.
This bot is designed to autonomously discover and trade mispriced events on Polymarket. Rather than filtering candidate markets with hand-coded rules, it delegates the hard judgment calls to Gemini Deep Research, which conducts live web research on each candidate before emitting structured trade recommendations.
Design Philosophy:
- AI-first market discovery — let Deep Research evaluate markets autonomously
- Conservative sizing — fractional Kelly (1/10), daily budget caps, per-bet hard limits
- Trade, don't hold — positions are actively managed based on sentiment and price swings rather than held to resolution
Six core modules:
| Module | Responsibility |
|---|---|
market_scanner.py |
Builds prompts and dispatches candidates to Gemini Deep Research |
gemini_driver.py |
Playwright-driven Chrome automation for Gemini's web UI |
report_parser.py |
Four-layer fallback JSON extraction with auto-repair |
risk_engine.py |
Fractional (1/10) Kelly position sizing |
executor.py |
Live order placement via py-clob-client |
dashboard.py |
Flask dashboard running at localhost:5050 |
A position monitor runs on a 5-minute cycle, triggering AI-reviewed hold/sell/add decisions at >200% profit or >50% loss thresholds.
- Python 3.12
- macOS or Linux (tested on Mac mini)
- Chrome browser with a signed-in Google account for Gemini access
- Polymarket wallet with funded Polygon USDC
- Gemini Advanced subscription (for Deep Research access)
git clone https://github.com/RobinVico/autonomous-polymarket-bot.git
cd autonomous-polymarket-botpython3.12 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
playwright install chromiumCopy the example file and fill in your own credentials:
cp .env.example .env
nano .envRequired variables:
POLY_PRIVATE_KEY— your Polymarket wallet private keyPOLY_FUNDER— your funder addressPOLY_SIGNATURE_TYPE— set to1for Polygon Gnosis SafePOLY_API_KEY,POLY_API_SECRET,POLY_PASSPHRASE— generate via01_setup_check.py
.env file. It is already listed in .gitignore.
Google blocks automation on fresh Chrome profiles. You must use a copy of your real Chrome profile:
cp -r ~/Library/Application\ Support/Google/Chrome/Default ~/.polymarket-bot-chrome-profile-copyThe Playwright driver loads this profile non-headlessly. Never run headless — Google will block sign-in.
python 01_setup_check.pyCopy the printed apiKey / secret / passphrase values back into your .env.
python 02_read_state.pypython 03_market_watch.pypython main_loop.pypython -m modules.dashboardThen open http://localhost:5050 in your browser.
| Setting | Default |
|---|---|
| AI recommendation frequency | 1 per 5-hour cycle |
| Daily budget cap | $5 |
| Per-bet hard limit | $0.50 – $1.00 |
| Kelly fraction | 1/10 |
| Position review interval | 5 minutes |
| Review trigger (profit) | +200% |
| Review trigger (loss) | -50% |
Adjust these in modules/risk_engine.py and modules/position_monitor.py.
Gemini runs out of output space after long Deep Research reports. The fix is a two-step flow:
- Trigger research and confirm with the Start Research button
- Send a follow-up message in the same conversation requesting only compact JSON
This isolates the structured output from the long analytical text.
Output format uses single-line RESULT_JSON: {...} with abbreviated fields (slug, mp, tp, conf, reason) rather than a nested structure. This dramatically reduces truncation risk.
Four extraction methods, in order:
RESULT_JSON:label match- Backtick JSON block
- Bare JSON scan from end of text
- Keyword extraction fallback
Auto-repair handles common truncation patterns (e.g., "position_actions":}).
- Copied profile required (Google blocks fresh profiles)
- Non-headless mode required (headless is detected and blocked)
- These are non-negotiable constraints
Gemini is explicitly instructed to default to hold and recommend selling only when fundamentals have fundamentally collapsed. Review history is tracked per position — follow-up AI calls are skipped unless the position moves an additional 30% after a prior hold decision.
autonomous-polymarket-bot/
├── modules/
│ ├── browser_manager.py
│ ├── claude_driver.py
│ ├── claude_research.py
│ ├── dashboard.py # Flask dashboard (main UI)
│ ├── db.py
│ ├── executor.py
│ ├── gemini_driver.py
│ ├── market_scanner.py
│ ├── phase_manager.py
│ ├── position_monitor.py
│ ├── prompts.py
│ ├── report_parser.py
│ └── risk_engine.py
├── 01_setup_check.py # Generate Polymarket API credentials
├── 02_read_state.py # Inspect wallet balance & positions
├── 03_market_watch.py # Market scanner dry-run
├── 04_rules_paper.py # Paper trading rules test
├── dashboard.py # Standalone Polymarket data API helper
├── main_loop.py # Main autonomous trading loop
├── .env.example # Environment variable template
├── .gitignore
├── LICENSE
└── README.md
- Live order placement is untested with real funds at time of initial release
-
get_balance()currently estimates balance by subtracting invested capital from a hardcoded starting value; proper web3 USDC balance querying is planned - Geo-blocking handling is external to this codebase
- Unit tests not yet included
This is a personal research project, but pull requests are welcome. Please do not submit PRs that:
- Add code enabling abusive trading strategies
- Remove or weaken the risk limits or disclaimers
- Introduce hardcoded credentials
MIT License — see LICENSE file for details.
- Polymarket for the prediction market platform
- py-clob-client for the trading client library
- Playwright for browser automation
- Google Gemini Deep Research for AI-powered market analysis
Built by @RobinVico — for learning and research purposes only.