[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-79381":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":15,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":35,"readmeContent":36,"aiSummary":37,"trendingCount":15,"starSnapshotCount":15,"syncStatus":14,"lastSyncTime":38,"discoverSource":39},79381,"polymarket-trading-bot","neuralCPL\u002Fpolymarket-trading-bot","neuralCPL","polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, polymarket trading bot, polymarket arbitrage bot, ","https:\u002F\u002Fgithub.com\u002FneuralCPL\u002Fpolymarket-trading-bot",null,"JavaScript",149,2582,2,0,234,57,false,"main",true,[22,23,24,25,26,27,28,29,30,31,32,33,34],"arbitrage","automated-trading","btc-trading","clob","copy-trading","defi","ethereum","nodejs","polygon","polymarket","prediction-markets","trading-bot","websocket","2026-06-12 04:01:24","# 🤖 Polymarket BTC Up\u002FDown Trading Bot\n\n> **A production-ready Node.js trading bot for Polymarket's fast-paced 5-minute markets**\n\n**Repository:** [github.com\u002FneuralCPL\u002Fpolymarket-trading-bot](https:\u002F\u002Fgithub.com\u002FneuralCPL\u002Fpolymarket-trading-bot)\n\n---\n\n## 🎯 Why This Bot?\n\nYou need trading software that actually works in production, not a toy script. This is it.\n\n| Feature | What You Get |\n|---------|-------------|\n| ✅ **Real CLOB Auth** | Full Polymarket authentication & order execution on Polygon |\n| ✅ **On-Chain Integration** | Approvals, merges, and redemptions built in |\n| ✅ **Live Order Book** | WebSocket monitoring with intelligent fallbacks |\n| ✅ **Safety First** | Risk limits, circuit breakers, graceful shutdowns |\n| ✅ **Copy Trading** | Mirror selected wallets automatically |\n\n---\n\n## 🚀 What This Bot Does\n\n### Core Strategy: Arbitrage + Copy Trading\n\n**The Main Arbitrage Engine:**\n1. 📍 Finds the next BTC Up\u002FDown 5-min market\n2. 📊 Posts buy ladders on both sides\n3. ⚡ Executes arbitrage when prices align\n4. 🔄 Merges matched pairs back into USDC\n5. 💰 Redeems winning positions after resolution\n\n**Plus:** Integrated wallet-following and a dedicated copy-trading module for high-frequency mimics.\n\n---\n\n## 📋 Before You Start\n\n### You'll Need:\n\n- ✔️ Node.js 18+\n- ✔️ Polymarket account (with proxy wallet)\n- ✔️ Polygon EOA private key\n- ✔️ USDC on Polygon\n- ✔️ Native MATIC for gas\n- ✔️ Reliable Polygon RPC endpoint\n\n### We Recommend:\n\n- 🔐 Use a **dedicated wallet** for bot operations\n- 💰 Start with **small size caps** (really small)\n- 🔌 Use a **private RPC** instead of public endpoints\n- 🧪 Test everything with `COPY_DRY_RUN=true` first\n\n---\n\n## ⚡ Quick Start (5 Minutes)\n\n### 1️⃣ Install\n\n```bash\nnpm install\n```\n\n### 2️⃣ Configure\n\n```bash\ncp .env.example .env\n```\n\nThen fill in these **required fields**:\n- `PRIVATE_KEY` — Your Polygon signer\n- `PROXY_WALLET` — Your Polymarket proxy address\n- `POLYGON_RPC` — Your Polygon RPC URL\n\n### 3️⃣ Run\n\n```bash\nnpm start\n```\n\nThat's it. Your bot is now:\n- Discovering markets\n- Posting ladders\n- Executing trades\n- Logging everything to `bot.log`\n\n---\n\n## 🛠️ Configuration Guide\n\n### Essential Settings\n\n| Setting | Purpose | Example |\n|---------|---------|---------|\n| `PRIVATE_KEY` | Polygon signer for approvals & orders | `0x...` |\n| `PROXY_WALLET` | Your Polymarket proxy address | `0x...` |\n| `POLYGON_RPC` | Polygon RPC endpoint | `https:\u002F\u002F...` |\n| `LOG_LEVEL` | Logging verbosity | `info`, `debug` |\n\n### Strategy Controls\n\nThese shape how aggressively your bot trades:\n\n```env\n# How much to spend per market\nMAX_SPEND_PER_MARKET=1000\n\n# Minimum edge before firing arb (e.g., 0.02 = 2%)\nTARGET_EDGE=0.02\n\n# Merge pairs when they reach this size\nMERGE_THRESHOLD_USDC=500\n\n# Maximum single taker order size\nMAX_TAKER_FILL_USDC=200\n\n# Stop if combined asks get too expensive\nCOMBINED_ASK_STOP=0.98\n\n# Hourly loss limit (circuit breaker)\nMAX_LOSS_PER_HOUR_USDC=500\n\n# How many price levels to post on\nLADDER_LEVELS=5\n\n# How much per level\nLADDER_SIZE_PER_LEVEL_USDC=100\n```\n\n### Copy Trading: Two Modes\n\n#### 🎬 **Integrated Mode** (Mirror during main run)\n\n```env\nTARGET_WALLET=0x...\nCOPY_TRADE_BUY_PERCENT=50\nCOPY_TRADE_POLL_MS=1000\n```\n\nSnapshots a target wallet and mirrors future buys.\n\n#### 🎯 **Dedicated Mode** (Buy-only, high-frequency)\n\n```env\nCOPY_TARGETS=0xWallet1,0xWallet2\nCOPY_SIZE_MODE=FIXED\nCOPY_FIXED_USDC=100\nCOPY_MAX_USDC_PER_TRADE=500\nCOPY_MAX_USDC_PER_HOUR=2000\nCOPY_DRY_RUN=true    # Enable to test first!\n```\n\nPolls public trade data and reacts immediately.\n\n---\n\n## 🎮 Running Modes\n\n### Main Arbitrage Bot\n```bash\nnpm start\n```\nor explicitly:\n```bash\nnpm run arb\n```\n\n### Development Mode (auto-reload)\n```bash\nnpm run dev\n```\n\n### Dedicated Copy Trader\n```bash\nnode src\u002Fcopy\u002Findex.js\n```\n\n---\n\n## 📁 What's Inside\n\n```\nsrc\u002F\n├── index.js              # Main bot lifecycle\n├── trader.js             # Per-market state machine\n├── market.js             # Polymarket API helpers\n├── clob.js               # CLOB client & auth\n├── onchain.js            # Approvals, merge, redeem\n├── copy-trader.js        # Integrated copy watcher\n├── pnl.js                # Profit\u002Floss tracking\n├── logger.js             # Structured logging\n└── copy\u002F\n    ├── index.js          # Copy trader entrypoint\n    ├── activityFeed.js   # Trade polling\n    ├── copyTrader.js     # Copy execution\n    └── config.js         # Copy settings\n```\n\n---\n\n## 🔒 Risk Controls (Built-In)\n\nYour bot has multiple safety mechanisms:\n\n| Control | What It Does |\n|---------|-------------|\n| `MAX_SPEND_PER_MARKET` | Caps spending per 5-min cycle |\n| `MAX_TAKER_FILL_USDC` | Caps single order size |\n| `MAX_INVENTORY_IMBALANCE_USDC` | Prevents lopsided positions |\n| `COMBINED_ASK_STOP` | Stops buying if market gets too expensive |\n| `MAX_LOSS_PER_HOUR_USDC` | Hourly loss circuit breaker |\n| `STOP_BUYING_BEFORE_CLOSE` | Prevents last-minute risk |\n\nThese aren't optional. They define how your bot behaves.\n\n---\n\n## 📊 Logging & Monitoring\n\nYour bot logs to **two places**:\n\n```\nConsole   → Colored, real-time output\nbot.log   → JSON structured logs (file)\n```\n\nUse these to:\n- 📈 Monitor live trading\n- 🐛 Debug failures\n- 📋 Review order history\n- ⏱️ Analyze timing & slippage\n\n---\n\n## ⚠️ Safety First\n\n### DO ✅\n- Start with **small caps** and scale gradually\n- Use a **dedicated wallet** for bot operations\n- **Test copy logic** with `COPY_DRY_RUN=true`\n- Review `bot.log` after each session\n- Use a **private RPC** for reliability\n- Keep **extra MATIC** for gas\n\n### DON'T ❌\n- Start with large sizing\n- Use a wallet with unrelated funds\n- Assume public RPC is production-ready\n- Skip the `.env.example` comments\n- Forget to verify your proxy wallet address\n- Run without understanding the strategy\n\n---\n\n## 🆘 Troubleshooting\n\n### Bot exits immediately?\n```\n✓ Check .env has PRIVATE_KEY and PROXY_WALLET\n✓ Verify values are not empty\n✓ For copy trading, also check COPY_TARGETS\n```\n\n### Orders failing or can't authenticate?\n```\n✓ Confirm signer matches your Polymarket account\n✓ Verify PROXY_WALLET is correct for that signer\n✓ Try a stable private RPC endpoint\n✓ Leave POLY_API_* blank to auto-derive credentials\n```\n\n### Copy trades not firing?\n```\n✓ Check target wallet is lowercased\n✓ Verify target is placing fresh BUY orders\n✓ Make sure spend caps aren't too restrictive\n✓ Confirm COPY_DRY_RUN is set as intended\n```\n\n### Merge or redeem failing?\n```\n✓ Did approvals complete successfully?\n✓ Do you have enough matched positions?\n✓ Is the market actually resolved?\n✓ Check bot.log for the error details\n```\n\n---\n\n## 🚦 Your First Run (Safest Path)\n\n1. **Fill `.env`** with real wallet values\n2. **Use a private RPC** for stability\n3. **Lower spend caps** significantly (like 25% of what you think)\n4. **Run with small sizing** and watch the logs\n5. **If testing copy:** set `COPY_DRY_RUN=true` first\n6. **Review bot.log** after 1-2 markets\n7. **Scale up gradually** only if everything looks good\n\n---\n\n## 📸 Performance Examples\n\nThe bot in action:\n\n- **1D Performance** — See daily profits\u002Flosses\n- **Weekly Snapshot** — Rolling week performance\n- **All-Time View** — Long-term trends\n- **Activity Log** — Real trades, real fills\n\n(See `img\u002F` folder for screenshots)\n\n---\n\n## 🔑 Advanced: CLOB Credentials\n\nThe bot can **auto-derive** CLOB credentials from your signer:\n\n```env\n# Leave these blank on first run\nPOLY_API_KEY=\nPOLY_API_SECRET=\nPOLY_API_PASSPHRASE=\n\n# Bot will generate them automatically\n```\n\nIf you want to supply them manually, get them from [Polymarket CLOB docs](https:\u002F\u002Fpolymarket.com).\n\n---\n\n## 💡 Strategy Deep Dive\n\n### The Arbitrage Loop\n\n1. **Wait for open** → Discover next market, idle until trading window\n2. **Post ladder** → Place buy orders at N price levels on both Up and Down\n3. **Monitor book** → WebSocket feed tracks best asks (REST fallback available)\n4. **Fire arb** → When `bestAskUp + bestAskDown \u003C 1 - TARGET_EDGE`, buy both sides\n5. **Merge pairs** → If you hold enough matched pairs, merge back to USDC\n6. **Close out** → Stop buying as market approaches end, cancel orders\n7. **Wait & redeem** → After resolution, redeem winning positions\n\n### The Copy Trading Flow\n\n**Integrated Mode:**\n- Snapshots target wallet on startup\n- Monitors for new buy activity\n- Mirrors increases at `COPY_TRADE_BUY_PERCENT`\n\n**Dedicated Mode:**\n- Polls target wallet trades every `COPY_POLL_MS`\n- Filters by price, slippage, staleness\n- Executes within spend caps\n- Supports multiple targets\n\n---\n\n## 📚 File Reference\n\n| File | Purpose |\n|------|---------|\n| `src\u002Findex.js` | Main loop, market discovery, graceful shutdown |\n| `src\u002Ftrader.js` | Per-market state machine (ladder, arb, merge, redeem) |\n| `src\u002Fmarket.js` | Polymarket API (discovery, positions, resolution) |\n| `src\u002Fclob.js` | CLOB REST + WebSocket, auth, order signing |\n| `src\u002Fonchain.js` | Polygon approvals, balances, merge, redeem TXs |\n| `src\u002Fcopy-trader.js` | Integrated target wallet mirroring |\n| `src\u002Fcopy\u002FactivityFeed.js` | High-freq trade polling |\n| `src\u002Fcopy\u002FcopyTrader.js` | Copy execution with filters & accounting |\n\n---\n\n## 🎓 Tips & Tricks\n\n### For Maximum Reliability\n- Use **Alchemy** or **Infura** private RPC (not free public endpoints)\n- Keep **2-3x gas reserves** in your wallet\n- Monitor **bot.log** in a separate terminal\n\n### For Copy Trading\n- Start with **tiny caps** (`COPY_FIXED_USDC=10`)\n- Use **`COPY_DRY_RUN=true`** for your first session\n- Pick **proven traders** for target wallets\n- Set **`COPY_MAX_SLIPPAGE` strictly** (0.01 = 1%)\n\n### For Arbitrage\n- **Lower `TARGET_EDGE`** to catch more opportunities (but with more risk)\n- **Increase `LADDER_LEVELS`** to post wider (but more capital tied up)\n- **Reduce `STOP_BUYING_BEFORE_CLOSE`** to trade longer (but more tail risk)\n\n---\n\n## ⚖️ Disclaimer\n\n**This software is for research and experienced operators only.** It is:\n\n- ❌ **NOT financial advice**\n- ❌ **NOT a guaranteed money machine**\n- ⚠️ **Full of risks:** market risk, execution risk, smart contract risk, RPC risk, operational risk\n\nYou are **100% responsible** for:\n- How you configure it\n- How you use it\n- What happens when you run it\n- All losses (and yes, there will be losses)\n\nReal-money trading is serious. Use this code wisely.\n\n---\n\n## 🤝 Need Help?\n\n1. **Check `bot.log`** — most errors are logged there\n2. **Review `.env.example`** — comments explain each setting\n3. **Read the strategy section** above — understand what the bot is doing\n4. **Start smaller** — if in doubt, reduce all caps by 10x and try again\n\n---\n\n**Ready to go?** Run `npm install` and update that `.env` file. Good luck! 🚀","该项目是一个针对Polymarket平台的自动化交易机器人，特别适用于快速波动的5分钟市场。其核心功能包括完整的Polymarket认证与订单执行、链上集成（如审批、合并和赎回）、实时订单簿监控以及内置的风险管理和复制交易功能。该机器人采用Node.js开发，支持通过WebSocket进行高效的数据交互，并具备智能回退机制以确保稳定性。它适合于希望在预测市场中实现高频交易策略的用户，尤其是那些对BTC上下波动感兴趣并希望通过套利和跟随交易来获取收益的投资者。此外，项目还提供了详细的配置指南和快速启动步骤，便于用户根据自身需求调整参数。","2026-06-01 03:48:22","CREATED_QUERY"]