{"id":50729508,"url":"https://github.com/gnanam1990/polymarket-copy-bot","last_synced_at":"2026-06-10T07:03:46.519Z","repository":{"id":347206144,"uuid":"1193210670","full_name":"gnanam1990/polymarket-copy-bot","owner":"gnanam1990","description":"Automatically copy trades from top Polymarket wallets. Multi-wallet tracking, smart ROI filtering, paper/live trading, WebSocket prices, real-time Flask dashboard.","archived":false,"fork":false,"pushed_at":"2026-03-27T01:47:18.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-03-27T14:17:13.321Z","etag":null,"topics":["asyncio","automated-trading","clob","copy-trading","crypto","defi","flask","paper-trading","polymarket","prediction-markets","python","trading-bot","websocket"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gnanam1990.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-27T01:38:49.000Z","updated_at":"2026-03-27T01:47:21.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/gnanam1990/polymarket-copy-bot","commit_stats":null,"previous_names":["gnanam1990/polymarket-copy-bot"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/gnanam1990/polymarket-copy-bot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnanam1990%2Fpolymarket-copy-bot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnanam1990%2Fpolymarket-copy-bot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnanam1990%2Fpolymarket-copy-bot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnanam1990%2Fpolymarket-copy-bot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gnanam1990","download_url":"https://codeload.github.com/gnanam1990/polymarket-copy-bot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gnanam1990%2Fpolymarket-copy-bot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34140776,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-10T02:00:07.152Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","automated-trading","clob","copy-trading","crypto","defi","flask","paper-trading","polymarket","prediction-markets","python","trading-bot","websocket"],"created_at":"2026-06-10T07:03:46.268Z","updated_at":"2026-06-10T07:03:46.512Z","avatar_url":"https://github.com/gnanam1990.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Polymarket Copy Trading Bot\n\n**Automatically copy trades from top Polymarket wallets with smart filtering, paper trading, and a real-time dashboard.**\n\n[![Python](https://img.shields.io/badge/Python-3.10+-3776AB?style=for-the-badge\u0026logo=python\u0026logoColor=white)](https://python.org)\n[![License](https://img.shields.io/badge/License-MIT-22c55e?style=for-the-badge)](LICENSE)\n[![Polymarket](https://img.shields.io/badge/Polymarket-CLOB-6366f1?style=for-the-badge)](https://polymarket.com)\n[![Flask](https://img.shields.io/badge/Flask-Dashboard-000000?style=for-the-badge\u0026logo=flask)](https://flask.palletsprojects.com)\n[![asyncio](https://img.shields.io/badge/asyncio-Async%20Engine-f59e0b?style=for-the-badge)](https://docs.python.org/3/library/asyncio.html)\n\n\u003c/div\u003e\n\n---\n\n## Architecture Overview\n\n```mermaid\ngraph TB\n    subgraph Input[\"🎯 Wallet Sources\"]\n        A1[Config File]\n        A2[Dashboard UI]\n        A3[REST API]\n    end\n\n    subgraph Core[\"⚙️ Core Engine\"]\n        B[Tracker] --\u003e|Trade Events| C[Copier]\n        C --\u003e|Open Position| D[Positions]\n        E[Prices] --\u003e|Bid/Ask/Mid| D\n    end\n\n    subgraph External[\"🌐 Polymarket APIs\"]\n        F1[Activity API]\n        F2[CLOB REST]\n        F3[CLOB WebSocket]\n    end\n\n    subgraph Output[\"📊 Output\"]\n        G[Flask Dashboard]\n        H[SSE Live Feed]\n        I[Position Persistence]\n    end\n\n    A1 \u0026 A2 \u0026 A3 --\u003e B\n    F1 --\u003e|Poll every 2s| B\n    F2 --\u003e|Order Book| E\n    F3 --\u003e|Price Stream| E\n    C --\u003e|Paper / Live| F2\n    D --\u003e G\n    D --\u003e H\n    D --\u003e I\n\n    style Input fill:#1e1b4b,stroke:#6366f1,color:#e0e7ff\n    style Core fill:#042f2e,stroke:#22c55e,color:#d1fae5\n    style External fill:#451a03,stroke:#f59e0b,color:#fef3c7\n    style Output fill:#1c1917,stroke:#a855f7,color:#f3e8ff\n```\n\n## Trade Execution Flow\n\n```mermaid\nflowchart LR\n    A[\"🔍 Detect Trade\"] --\u003e B{\"Action?\"}\n    B --\u003e|BUY| C{\"Price\\n3¢ – 70¢?\"}\n    B --\u003e|SELL| W[\"⚠️ Whale Exit Alert\"]\n    C --\u003e|No| X[\"Skip\"]\n    C --\u003e|Yes| D{\"ROI\\n≥ 30%?\"}\n    D --\u003e|No| X\n    D --\u003e|Yes| E{\"Max\\nPositions?\"}\n    E --\u003e|Full| X\n    E --\u003e|OK| F{\"Duplicate\\nCheck\"}\n    F --\u003e|Dup| X\n    F --\u003e|New| G{\"Mode?\"}\n    G --\u003e|Paper| H[\"📝 Simulate Fill\\n+ Slippage \u0026 Gas\"]\n    G --\u003e|Live| I[\"💰 CLOB FOK Order\"]\n    H \u0026 I --\u003e J[\"📊 Track Position\\n+ Live PnL\"]\n\n    style A fill:#3b82f6,stroke:#1d4ed8,color:#fff\n    style W fill:#a855f7,stroke:#7c3aed,color:#fff\n    style X fill:#ef4444,stroke:#dc2626,color:#fff\n    style H fill:#f59e0b,stroke:#d97706,color:#fff\n    style I fill:#22c55e,stroke:#16a34a,color:#fff\n    style J fill:#6366f1,stroke:#4f46e5,color:#fff\n```\n\n## Features\n\n| Feature | Description |\n|---------|-------------|\n| **Multi-Wallet Tracking** | Monitor unlimited Polymarket wallets simultaneously |\n| **Smart Copy Engine** | Filters by entry price range, ROI threshold, dedup window |\n| **Paper Trading** | Full simulation with slippage, gas fees, and FOK rejection |\n| **Live Trading** | Real CLOB orders via Polymarket API (FOK) |\n| **Web Dashboard** | Real-time positions, PnL, trade feed at `localhost:8080` |\n| **Profile Resolver** | Add wallets by URL, username, or `0x` address |\n| **Whale Exit Alerts** | Detects when tracked wallets sell positions you hold |\n| **Live Prices** | WebSocket + REST fallback for bid/ask/mid |\n| **Auto Settlement** | Detects market resolution, credits wins, debits losses |\n| **Hot-Reload Config** | Change settings without restart |\n\n## Quick Start\n\n```bash\n# Clone\ngit clone https://github.com/gnaneshwarvasala/polymarket-copy-bot.git\ncd polymarket-copy-bot\n\n# Install\npip install -r requirements.txt\n\n# Configure\ncp config.example.toml config.toml\n# Edit config.toml — add wallet addresses to track\n\n# Run (paper mode by default)\npython bot.py\n\n# Dashboard → http://localhost:8080\n```\n\n## Configuration\n\n```toml\n[mode]\npaper = true                    # true = simulation, false = real USDC\npaper_balance = 1000.0\n\n[copy]\nmin_profit_pct = 30.0           # Min ROI% to copy (30 = max entry ~77¢)\nmax_entry_price = 0.70          # Max entry price (0.70 = 70¢)\nmin_entry_price = 0.03          # Skip dust trades below 3¢\nposition_size = 10.0            # USDC per trade\nmax_positions = 20              # Max concurrent positions\ndedup_window_secs = 60          # Block same market+side within N seconds\n\n[wallets]\ntrack = [\n    \"0xed107a85a4585a381e48c7f7ca4144909e7dd2e5\",\n]\n\n[poll]\ninterval_secs = 2\ntrades_per_wallet = 20\n\n[dashboard]\nenabled = true\nport = 8080\n```\n\n## Adding Wallets\n\nThree ways to add wallets — all formats auto-resolve:\n\n```\nhttps://polymarket.com/profile/scottilicious   →  profile URL\nscottilicious                                   →  username\n0x000d257d2dc7616feaef4ae0f14600fdf50a758e      →  direct address\n```\n\n| Method | How |\n|--------|-----|\n| **Config** | Add to `[wallets] track` in `config.toml` |\n| **Dashboard** | Type in the \"Add wallet\" field |\n| **API** | `POST /api/wallet/add {\"input\": \"scottilicious\"}` |\n\n## System Architecture\n\n```mermaid\ngraph LR\n    subgraph bot.py[\"🚀 bot.py — Entry Point\"]\n        direction TB\n        LOAD[Load Config] --\u003e INIT[Init Components]\n        INIT --\u003e START[Start Async Tasks]\n    end\n\n    subgraph tracker.py[\"🔍 tracker.py\"]\n        POLL[Poll Activity API] --\u003e DETECT[Detect New Trades]\n        DETECT --\u003e EMIT[Emit TradeEvent]\n    end\n\n    subgraph copier.py[\"📋 copier.py\"]\n        FILTER[Filter Signal] --\u003e EXEC[Execute Trade]\n        EXEC --\u003e SETTLE[Settlement Loop]\n    end\n\n    subgraph positions.py[\"📊 positions.py\"]\n        OPEN[Open Position] --\u003e TRACK[Track PnL]\n        TRACK --\u003e CLOSE[Settle / Close]\n    end\n\n    subgraph prices.py[\"💹 prices.py\"]\n        WS[WebSocket Stream] --\u003e CACHE[Price Cache]\n        REST[REST Fallback] --\u003e CACHE\n        CACHE --\u003e PUSH[Push to Positions]\n    end\n\n    subgraph dashboard.py[\"🖥️ dashboard.py\"]\n        FLASK[Flask Server] --\u003e SSE[SSE Live Feed]\n        FLASK --\u003e API[REST API]\n        FLASK --\u003e UI[Web UI]\n    end\n\n    subgraph resolver.py[\"🔗 resolver.py\"]\n        RESOLVE[URL / Username / Address → Proxy Wallet]\n    end\n\n    bot.py --\u003e tracker.py --\u003e copier.py --\u003e positions.py\n    prices.py --\u003e positions.py\n    dashboard.py --\u003e positions.py\n    dashboard.py --\u003e resolver.py\n\n    style bot.py fill:#1e3a5f,stroke:#3b82f6,color:#bfdbfe\n    style tracker.py fill:#1a2e1a,stroke:#22c55e,color:#bbf7d0\n    style copier.py fill:#3b1f0b,stroke:#f59e0b,color:#fef3c7\n    style positions.py fill:#2d1b4e,stroke:#a855f7,color:#e9d5ff\n    style prices.py fill:#1e3a5f,stroke:#3b82f6,color:#bfdbfe\n    style dashboard.py fill:#1c1917,stroke:#71717a,color:#e4e4e7\n    style resolver.py fill:#3b0a1e,stroke:#ec4899,color:#fce7f3\n```\n\n## Dashboard\n\nOpen `http://localhost:8080` after starting the bot:\n\n| Panel | Shows |\n|-------|-------|\n| **Stats Bar** | Balance, Unrealized PnL, Realized PnL, Total PnL |\n| **Positions Table** | Market, Side, Size, Entry, Bid, Ask, Spread, PnL |\n| **Live Feed** | Real-time stream of detections, copies, fills, settlements |\n| **Wallet List** | All tracked wallets with add/remove controls |\n\n## API Reference\n\n| Endpoint | Method | Description |\n|----------|--------|-------------|\n| `/api/status` | `GET` | Bot status, balance, position count |\n| `/api/positions` | `GET` | All open positions with live prices |\n| `/api/wallets` | `GET` | Tracked wallets list |\n| `/api/wallet/add` | `POST` | Add wallet — `{\"input\": \"0x...\"}` |\n| `/api/wallet/remove` | `POST` | Remove wallet — `{\"wallet\": \"0x...\"}` |\n| `/api/trades` | `GET` | Trade history |\n| `/api/feed` | `GET` | SSE live event stream |\n| `/api/pause` | `POST` | Pause trading |\n| `/api/resume` | `POST` | Resume trading |\n\n## Settlement Flow\n\n```mermaid\nsequenceDiagram\n    participant S as Settlement Loop\n    participant C as CLOB API\n    participant P as Positions\n    participant B as Balance\n\n    loop Every 30s\n        S-\u003e\u003eP: Get open positions\n        loop Each position\n            S-\u003e\u003eC: Check market resolution\n            alt Market resolved — WIN\n                S-\u003e\u003eP: Settle (WON)\n                P-\u003e\u003eB: Credit payout (size / entry_price)\n                Note right of B: ✅ Balance increases\n            else Market resolved — LOSS\n                S-\u003e\u003eP: Settle (LOST)\n                Note right of B: ❌ Size already deducted\n            else Still open\n                Note right of S: Skip — check next cycle\n            end\n        end\n    end\n```\n\n## Live Trading\n\n\u003e **Use at your own risk. Always start with paper mode.**\n\nSet environment variables:\n\n```bash\nexport POLY_KEY=\"your-api-key\"\nexport POLY_SECRET=\"your-api-secret\"\nexport POLY_PASSPHRASE=\"your-passphrase\"\nexport POLY_PRIVATE_KEY=\"your-private-key\"\n```\n\nThen in `config.toml`:\n\n```toml\n[mode]\npaper = false\n```\n\n## Tech Stack\n\n| Component | Technology |\n|-----------|-----------|\n| **Runtime** | Python 3.10+ / asyncio |\n| **HTTP Client** | aiohttp |\n| **WebSocket** | websockets |\n| **Dashboard** | Flask + Server-Sent Events |\n| **Config** | TOML (tomli) |\n| **Persistence** | JSON file storage |\n\n## License\n\n[MIT](LICENSE)\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n`#polymarket` `#copy-trading` `#trading-bot` `#python` `#prediction-markets` `#crypto` `#defi` `#asyncio` `#flask` `#websocket` `#paper-trading` `#clob` `#automated-trading`\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnanam1990%2Fpolymarket-copy-bot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgnanam1990%2Fpolymarket-copy-bot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgnanam1990%2Fpolymarket-copy-bot/lists"}