Skip to content

Polymarket CopyTrading Bot An automated polymarket copytrading bot designed to replicate the strategies of top-performing Polymarket traders across all active prediction markets. Polymarket Copy Trading Bot Polymarket copy Trading Bot Polymarket Copy trading Bot Polymarket Copy Trading bot

License

Notifications You must be signed in to change notification settings

021zaidrasool-dotcom/Copy-trading-bot-polymarket

Β 
Β 

Repository files navigation

Polymarket Copy Trading Bot

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.

TypeScript Node.js MongoDB License

Contact info

Gmail: [email protected]

Telegram: @SOLBenjaminCup

X : @.benjamincup

πŸš€ Quick Start

Prerequisites

  • Node.js 18+
  • MongoDB (local or cloud)
  • Ethereum wallet with USDC on Polygon
  • Polymarket API credentials

Installation

git clone https://github.com/Benjamin-cup/Copy-trading-bot-polymarket
cd Copy-trading-bot-polymarket
npm install

Setup

Choose one of two setup methods:

Option 1: Interactive Setup (Recommended)

npm run setup

Option 2: Manual Configuration

Copy .env.example to .env and fill in your values.

Health Check

npm run health-check

Start Trading

npm start

πŸ“‹ What You Need

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

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   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   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Components

  • 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

πŸ“– Usage

Basic Commands

# 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

Advanced Commands

# 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

βš™οΈ Configuration

Environment Variables

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 βœ…

Optional Settings

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

πŸ”§ Troubleshooting

Common Issues

"Invalid wallet address"

  • Ensure your PROXY_WALLET starts with 0x and is 42 characters long
  • Verify the address checksum

"Database connection failed"

  • Check your MONGODB_URI format
  • Ensure MongoDB is running and accessible
  • Verify network connectivity

"Insufficient balance"

  • Ensure your wallet has enough USDC for trades
  • Check the balance on Polygon network
  • Verify the USDC_CONTRACT_ADDRESS is correct

"Circuit breaker open"

  • External API is failing repeatedly
  • Check Polymarket API status
  • Wait for automatic recovery or restart the bot

Getting Help

  1. Run npm run health-check for diagnostics
  2. Check docs/GETTING_STARTED.md for detailed setup
  3. Review logs in the logs/ directory
  4. Open an issue on GitHub

πŸ“š Documentation

πŸ§ͺ Testing

# Run all tests
npm test

# Run with coverage
npm run test:coverage

# Watch mode
npm run test:watch

πŸ“Š Monitoring

The 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

πŸ”’ Security

  • 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

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. Submit a pull request

πŸ“„ License

This project is licensed under the ISC License - see the LICENSE file for details.

⚠️ Disclaimer

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! πŸš€

About

Polymarket CopyTrading Bot An automated polymarket copytrading bot designed to replicate the strategies of top-performing Polymarket traders across all active prediction markets. Polymarket Copy Trading Bot Polymarket copy Trading Bot Polymarket Copy trading Bot Polymarket Copy Trading bot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 98.9%
  • Other 1.1%