π Polymarket Trading Bot (Copy Trading)
π¬ Contact
- Telegram: https://t.me/dexoryn_here
- GitHub: https://github.com/dexorynLabs
- X (Twitter): https://x.com/dexoryn
For the latest, more effective version of the bot or help running it, please contact the links above.
Advanced Polymarket trading bot for copy trading in prediction markets. Monitors whale wallets and copies their trades with intelligent position sizing, adaptive take-profit, and trailing stop-loss protection.
SEO keywords: polymarket bot, polymarket trading bot, polymarket copy trading bot, prediction market bot
β¨ Features
Core Trading
- π― Smart Copy Trading β Real-time monitoring of whale wallets with instant trade replication
- π Proportional Sizing β Automatically scales trade sizes based on your balance vs whale's
- π Position Limits β Configurable max buys per token to prevent overexposure
- β±οΈ Cooldown System β Prevents rapid rebuying of the same position
- βΈοΈ Auto-Pause β Stops buying when balance drops below minimum stake
Advanced Take-Profit System
- π Adaptive Trailing Stop β Dynamic stop-loss that tracks peak prices
- Default: 15% trailing stop from peak
- Sports markets: 25% trailing stop (higher volatility tolerance)
- π° Profit Triggers β Automatically activates at +15% profit
- π Smart Order Updates β Repositions orders as market moves up
- π¨ Emergency Exit β Aggressive market sells when stop-loss triggered
- πΎ State Persistence β Saves tracking state for recovery after restart
- β‘ Fast Monitoring β 3-second checks for volatile markets
Risk Management
- π‘οΈ Position-Based Stops β Protects profits without closing at a loss
- π Stop-Loss Protection β Configurable stop-loss percentage (can be disabled)
- π Sports Market Detection β Wider stops for high-volatility sports markets
- π’ Decimal Precision β Proper rounding for API compliance (SELL: 2 decimals, BUY: 4 decimals)
Session Tracking
- π Real-Time P&L β Live session profit/loss tracking
- π Win/Loss Stats β Track winning and losing trades
- π΅ Balance Monitoring β Real-time USDC and position value display
π Quick Start
# Install dependencies
npm install
# Setup environment
cp env.example .env
# Edit .env with your private key and wallet address
# Configure tracking (edit config.json)
# Add whale wallets, adjust stake sizes, set limits
cp config.example.json config.json
# Build and run
npm run build
npm run bot
βοΈ Configuration
Environment Variables (.env)
PRIVATE_KEY=0xYourPrivateKey # MetaMask/Wallet private key
FUNDER_ADDRESS=0xYourTradingWallet # Polymarket wallet address
TAKE_PROFIT_PERCENT=15 # Profit trigger threshold (%)
DEBUG=false # Enable verbose logging
Trading Settings (config.json)
{
"wallets_to_track": [
"0x33f6d97080e5215eb2cf679531496ace0330e0de"
],
"mode": "proportional", // Sizing mode
"min_stake": 7, // Minimum trade size (USDC)
"max_stake": 300, // Maximum trade size (USDC)
"max_buys_per_token": 3, // Max positions per token
"cooldown_minutes": 30, // Rebuy cooldown period
"stop_loss_percent": 15, // Trailing stop % (default)
"stop_loss_enabled": true, // Enable/disable stop-loss
"skip_sports": false // Skip sports markets
}
Configuration Parameters
| Parameter | Default | Description |
|---|---|---|
min_stake | 7 | Minimum trade size in USDC |
max_stake | 300 | Maximum trade size in USDC |
max_buys_per_token | 3 | Max number of buys for same token |
cooldown_minutes | 30 | Minutes before allowing rebuy |
stop_loss_percent | 15 | Trailing stop % from peak (default markets) |
stop_loss_enabled | true | Enable automatic stop-loss exits |
skip_sports | false | Skip sports markets entirely |
Note: Sports markets automatically use 25% trailing stop regardless of stop_loss_percent setting.
π How It Works
Trading Flow
- Monitor β Bot polls tracked wallets every 5 seconds for new trades
- Analyze β Validates trade against position limits and cooldown rules
- Size β Calculates proportional stake based on balance ratio
- Execute β Places market order matching whale's side (BUY/SELL)
- Track β Monitors position for take-profit opportunities
- Exit β Automatically sells when profit target or stop-loss triggers
Take-Profit Logic
1. Position reaches +15% profit β Start tracking
2. Price continues up β Update trailing stop to track new peaks
3. If price drops 15% from peak β Trigger stop-loss
4. Place limit order 2% below current price
5. If order not filled β Update price or emergency exit
Position Management
- Multiple Buys: Bot can buy same token up to 3 times (configurable)
- Cooldown Protection: 30-minute cooldown prevents rapid rebuying
- Per-Wallet Tracking: Sells only match specific wallet's position
- State Persistence: Tracking survives bot restarts
π Finding Whale Wallets
Top Traders
- Polymarket Leaderboard β Official rankings
- Predictfolio β Analytics and insights
Tips
- Look for consistent profit over volume
- Track multiple whales for diversification
- Monitor their sports vs politics preferences
- Check average position sizes vs your budget
π Commands
| Command | Description |
|---|---|
npm run bot | Start the trading bot |
npm run balance | Check wallet balance and positions |
npm run build | Compile TypeScript to JavaScript |
npm run dev | Development mode with hot reload |
npm run clean | Remove compiled files |
ποΈ Architecture
src/
βββ main.ts # CLI entry point
βββ bot.ts # Main bot orchestrator
βββ watcher.ts # Wallet monitoring
βββ trader.ts # Trade execution (CLOB API)
βββ executor.ts # Position management
βββ take-profit.ts # Adaptive take-profit system
βββ sizing.ts # Proportional sizing logic
βββ risk.ts # Risk management rules
βββ pnl-tracker.ts # P&L and stats tracking
βββ wallet.ts # Wallet and balance management
βββ api.ts # Polymarket REST API
βββ config.ts # Configuration loading
π Requirements
- Node.js 18+ (with ESM support)
- Polymarket Account with USDC funded
- MetaMask Wallet linked to Polymarket
- Private Key exported from MetaMask
π Troubleshooting
Common Issues
"Order failed: invalid amounts"
- Fixed in latest version with proper decimal rounding
- Rebuild:
npm run build
"Not enough balance"
- Check balance:
npm run balance - Deposit more USDC to Polymarket
- Lower
min_stakein config.json
"Position likely closed"
- Take-profit already executed by smart contract
- Position was manually closed on Polymarket
- Bot will auto-cleanup tracking
"502/503 CLOB errors"
- Automatic retry logic handles temporary API issues
- If persistent, check Polymarket API status
β οΈ Risk Warning
This bot is for educational purposes. Trading prediction markets involves substantial risk of loss.
- Start with small stakes to test
- Never trade more than you can afford to lose
- Whale wallets can be wrong
- Markets can gap against you
- API issues can prevent exits
- Test thoroughly before scaling up
π License
MIT License - see LICENSE file for details
π€ Contributing
Issues and pull requests welcome! Please test thoroughly before submitting.
π‘ Tips
- Start with
min_stake: 7andmax_stake: 50until comfortable - Enable stop-loss initially:
stop_loss_enabled: true - Track 2-3 whales maximum to start
- Monitor first few days closely
- Keep at least 2x
max_stakein balance for opportunities - Sports markets are more volatile β use with caution
π Roadmap
- Web dashboard for monitoring
- Multi-wallet support (multiple trading accounts)
- Advanced analytics and backtesting
- Discord/Telegram notifications
- Custom strategy scripts
- Paper trading mode
Built with TypeScript + Polymarket CLOB API