The Polymarket Copy Trading Bot is an automated trade replication system that mirrors the activity of consistently profitable Polymarket participants. It operates continuously, dynamically scales position sizes relative to available capital, and executes trades in real time to ensure alignment with source strategies.
Gmail: [email protected]
Telegram: @SOLBenjaminCup
X : @.benjamincup
- Node.js 18+
- MongoDB (local or cloud)
- Ethereum wallet with USDC on Polygon
- Polymarket API credentials
git clone https://github.com/Benjamin-cup/Copy-trading-bot-polymarket
cd Copy-trading-bot-polymarket
npm installChoose one of two setup methods:
npm run setupCopy .env.example to .env and fill in your values.
npm run health-checknpm start| Component | Status | Notes |
|---|---|---|
| β Node.js 18+ | Required | Runtime environment |
| β MongoDB | Required | Data storage |
| β Ethereum Wallet | Required | Trading wallet |
| β USDC on Polygon | Required | Trading capital |
| β Polymarket Account | Required | API access |
| β RPC Endpoint | Required | Polygon network access |
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Trade Monitor βββββΆβ Trade Executor βββββΆβ Execution Engineβ
β β β β β β
β β’ API Polling β β β’ Aggregation β β β’ Order Posting β
β β’ Data Storage β β β’ Validation β β β’ Error Handlingβ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Circuit β β Order β β Polymarket β
β Breaker β β Validator β β API β
β β β β β β
β β’ Failure β β β’ Balance Check β β β’ Trade Orders β
β β’ Recovery β β β’ Position Val. β β β’ Market Data β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Trade Monitor: Continuously monitors selected traders' activities
- Trade Aggregator: Groups small trades to meet minimum order sizes
- Order Validator: Ensures trades can be executed safely
- Execution Engine: Places orders on Polymarket
- Circuit Breaker: Prevents cascading failures
- Error Handler: Comprehensive error management and recovery
# Start the bot
npm start
# Interactive setup
npm run setup
# Health check
npm run health-check
# View all commands
npm run help
# Generate API documentation
npm run docs# Check your positions
npm run check-stats
# Check trader positions
npm run check-pnl
# Run simulations
npm run simulate
# Close positions
npm run close-resolved| Variable | Description | Required |
|---|---|---|
MONGODB_URI |
MongoDB connection string | β |
PROXY_WALLET |
Your trading wallet address | β |
PRIVATE_KEY |
Wallet private key | β |
USER_ADDRESSES |
Trader addresses to copy (comma-separated) | β |
CLOB_HTTP_URL |
Polymarket API URL | β |
RPC_URL |
Polygon RPC endpoint | β |
USDC_CONTRACT_ADDRESS |
USDC contract on Polygon | β |
| Variable | Default | Description |
|---|---|---|
FETCH_INTERVAL |
30 | Seconds between API checks |
TRADE_AGGREGATION_ENABLED |
true | Enable trade aggregation |
TRADE_AGGREGATION_WINDOW_SECONDS |
300 | Aggregation time window |
LOG_LEVEL |
INFO | Logging verbosity |
- Ensure your
PROXY_WALLETstarts with0xand is 42 characters long - Verify the address checksum
- Check your
MONGODB_URIformat - Ensure MongoDB is running and accessible
- Verify network connectivity
- Ensure your wallet has enough USDC for trades
- Check the balance on Polygon network
- Verify the
USDC_CONTRACT_ADDRESSis correct
- External API is failing repeatedly
- Check Polymarket API status
- Wait for automatic recovery or restart the bot
- Run
npm run health-checkfor diagnostics - Check
docs/GETTING_STARTED.mdfor detailed setup - Review logs in the
logs/directory - Open an issue on GitHub
- Getting Started Guide
- API Documentation - Run
npm run docsto generate - Deployment Guide
- Simulation Guide
- Improvements
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Watch mode
npm run test:watchThe bot provides comprehensive monitoring:
- Real-time Logging: Color-coded console output
- Health Checks: System component validation
- Position Tracking: Portfolio monitoring
- Performance Metrics: Trade success rates
- Error Recovery: Automatic failure handling
- Private keys are encrypted in memory
- No sensitive data in logs
- Circuit breakers prevent cascade failures
- Input validation on all user data
- Secure API key handling
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
This project is licensed under the ISC License - see the LICENSE file for details.
This software is for educational and research purposes. Trading cryptocurrencies and prediction markets involves significant risk. Always trade with caution and never invest more than you can afford to lose. The authors are not responsible for any financial losses incurred through the use of this software.
Happy Trading! π