The Ultimate Open-Source Automated Trading Bot for Polymarket
Created by: @Mr_CryptoYT
- β 4-Layer Protection System: Daily (5%), Monthly (15%), Drawdown (25%), Total Loss Halt (40%)
- β Smart Money Filtering: Only follow traders with 60%+ win rate, 1.5x profit factor, and consistency checks
- β Dynamic Position Sizing: Automatically reduces during losses, increases during wins
- β Enhanced Monitoring: Real-time risk status with breach alerts
- β Minimum Trade Enforcement: All DipArb positions β₯ $1.50 (guaranteed exit capability)
- β Gas Fee Accounting: Higher profit thresholds to cover transaction costs
- β Whale Trade Detection: Prevents following lucky one-hit wonders
- β Permanent Halt: Trading stops automatically at 40% total loss
This guide will take you from A to Z on how to set up, configure, and run your own trading bot safely.
- Prerequisites
- Installation
- Configuration
- Running the Bot
- Dashboard Guide
- Risk Management
- Strategies Explained
- Troubleshooting
- Safety & Risks
Before you start, you need three things:
- OS: Windows, Mac, or Linux.
- Node.js: You must have Node.js installed (Version 18 or higher).
- Download Node.js here (Choose "LTS" version).
- Git: Required to download the code.
- A Polymarket Account: Log in to Polymarket.com.
- USDC (Polygon): You need funds to trade.
- USDC.e is the specific token used on Polygon for Polymarket.
- MATIC (Polygon): You need a small amount ($1-$5) for gas fees.
- You need the Private Key of your wallet (e.g., from MetaMask or your Polymarket proxy wallet).
- Security Note: Never share this key with anyone.
Open your terminal (Command Prompt or PowerShell on Windows, Terminal on Mac) and run these commands one by one.
Download the bot code to your computer.
git clone https://github.com/MrFadiAi/Polymarket-bot.git
cd Polymarket-bot(Note: If you downloaded the ZIP file instead, just unzip it and open the folder in your terminal)
This installs all the "parts" the bot needs to run and builds the dashboard interface.
# Install main dependencies
npm install
# Build the dashboard (Critical Step!)
cd dashboard
npm install
npm run build
cd ..This process might take 1-3 minutes.
This is the most important step. We need to tell the bot your wallet details.
- Find the file named
.env.examplein the folder. - Copy it and rename the copy to
.env.
Open the .env file with any text editor (Notepad, VS Code) and fill in your details:
# ==============================================
# π WALLET CONFIGURATION (REQUIRED)
# ==============================================
# Your Wallet Private Key (Export from MetaMask)
# Format: 0x...
POLYMARKET_PRIVATE_KEY=0xYourPrivateKeyHere
# ==============================================
# βοΈ BOT SETTINGS
# ==============================================
# CAPITAL (Your risk budget - NOT your wallet balance)
# This determines position sizes and risk limits
# Start with a small amount for testing
CAPITAL_USD=250
# DRY RUN MODE
# "true" = Simulation Mode (No real money used, SAFE to test)
# "false" = Live Trading (Real money used, BE CAREFUL)
DRY_RUN=true
# π RISK MANAGEMENT (Optional - defaults are conservative)
DAILY_MAX_LOSS_PCT=0.05 # 5% daily loss limit
MONTHLY_MAX_LOSS_PCT=0.15 # 15% monthly loss limit
MAX_DRAWDOWN_PCT=0.25 # 25% drawdown from peak
TOTAL_MAX_LOSS_PCT=0.40 # 40% total loss = permanent halt
# API Keys (Optional but recommended for speed)
# Get a free key from specific providers if you want better performance
# ALCHEMY_KEY=...- Start with
DRY_RUN=trueandCAPITAL_USD=50for testing - Only change to
DRY_RUN=falsewhen you are 100% sure everything works
Now the fun part! Let's start the bot with the visual dashboard.
Run this command:
npx tsx bot-with-dashboard.ts- The terminal will show startup logs.
- It will verify your wallet connection.
- The Dashboard will open automatically in your browser at
http://localhost:3001.
If it doesn't open, just click that link.
The dashboard is your command center with enhanced risk monitoring.
- Mode Indicator: Shows if you are in π΄ LIVE or π’ DRY RUN mode.
- Mode Toggle: Click the "Switch to LIVE/DRY RUN" button to instantly switch modes.
- Balances: Real-time view of your MATIC and USDC.
- PnL Panel: Tracks your Profit and Loss per session.
- Daily Limit: Shows usage of 5% daily loss limit
- Monthly Limit: Shows usage of 15% monthly loss limit
- Drawdown: Current drawdown from peak capital
- Consecutive Tracker: Win/loss streak counter
- Status Indicators: π΄ BREACHED or β OK for each limit
- Strategy Toggles: Enable/disable strategies in real-time
- Emergency Stop: Instantly halt all trading
- Panic Sell: Close all positions (use with caution)
The bot now has 4 layers of protection to safeguard your capital:
- What it does: Stops trading if you lose 5% in one day
- Action: Pauses for 60 minutes, then resumes
- Example: With $250 capital, stops at -$12.50 daily loss
- What it does: Stops trading if you lose 15% in 30 days
- Action: Pauses for 30 days (rest of month)
- Example: With $250 capital, stops at -$37.50 monthly loss
- What it does: Monitors drop from your peak capital
- Action: Pauses for 7 days if exceeded
- Example: Peak $300, stops if drops below $225
- What it does: PERMANENT HALT if total loss reaches 40%
- Action: Stops trading entirely, requires manual restart
- Example: With $250 capital, halts at -$100 total loss
The bot now adapts position sizes based on performance:
- Base Size: 2% of capital (down from 3%)
- During Losses: Reduces by 20% per consecutive loss
- During Wins: Increases by 10% per consecutive win (capped at 5%)
- Example:
- Normal: $250 Γ 2% = $5/trade
- After 3 losses: $5 Γ 0.8 Γ 0.8 = $3.20/trade
- After 5 wins: $5 Γ 1.4 = $7/trade (capped at $12.50)
The bot comes with 4 powerful strategies. You can toggle them ON/OFF in the dashboard.
- Concept: Finds markets where
YES Price + NO Price < $1.00. - Action: Buys both sides immediately.
- Profit: Guaranteed math-based profit when the market resolves to $1.00.
- π v3.1: Higher profit threshold (1%) to cover gas fees
- Risk: Extremely Low.
- Concept: Watches for panic selling in 15-minute crypto markets (BTC, ETH).
- Trigger: If price crashes >15% in 3 seconds.
- Action: Buys the dip (Leg 1) and hedges with the opposite side (Leg 2).
- π v3.1: Minimum $1.50 trade value (all positions can be exited)
- Risk: Low-Medium (hedged positions).
- Concept: Tracks the top profitable traders on the leaderboard.
- π Strict Filtering:
- β Minimum 60% win rate (up from 50%)
- β Minimum $500 total PnL (up from $100)
- β Profit Factor β₯ 1.5x (wins/losses ratio)
- β Consistency score 70%+ (recent performance)
- β No whale trades (max 30% PnL from one trade)
- Action: Copies their trades automatically.
- Risk: Medium (depends on trader quality).
- Concept: Tools for manual trading with super-powers.
- Features:
- FOK (Fill or Kill): Ensures your whole order fills or cancels.
- Sniper: Quick buy buttons slightly above market price.
- π v3.1: Stop-loss (15%), Take-profit (25%), Max hold (7 days)
- Risk: Controlled (with new limits).
"Command not found" error?
- Make sure you installed Node.js. Restart your computer if you just installed it.
"Connection Failed"?
- Check your internet.
- Verify your
POLYMARKET_PRIVATE_KEYis correct in.env.
"Insufficient Funds"?
- You need both USDC (for trades) and MATIC (for gas) on the Polygon Network.
"Trade value below minimum"?
- This is the new $1.50 minimum protection. Increase your
CAPITAL_USDor wait for better prices.
Bot paused unexpectedly?
- Check the Risk Status panel - you may have hit a daily/monthly/drawdown limit.
- This is a safety feature working as intended.
- Multi-Layer Limits: 4 levels of automatic protection
- Quality Trader Filtering: Only follow proven, consistent traders
- Position Size Limits: Maximum 5% per trade, adapts to performance
- Minimum Trade Values: All positions can be exited (no stuck trades)
- Permanent Halt: Trading stops at 40% total loss
- Private Keys: Your key gives full access to your funds. Keep it safe.
- Start Small:
- Use Dry Run first (24-48 hours)
- Then test with $50 real money
- Scale up gradually to $250+
- Monitor Regularly: Check the Risk Status panel daily
- Understand Limits: Know what triggers each safety layer
- Capital Management: Set
CAPITAL_USDto what you can afford to lose
- Day 1-2: Dry run mode (
DRY_RUN=true,CAPITAL_USD=50) - Day 3-9: Live testing (
DRY_RUN=false,CAPITAL_USD=50) - Day 10+: Scale up if profitable (
CAPITAL_USD=250)
If something goes wrong:
- Click "Emergency Stop" in dashboard
- Or press
Ctrl+Cin terminal - Use "Panic Sell" only if absolutely necessary
- Original SDK Documentation: For developers who want to use the raw SDK, see SDK_DOCUMENTATION.md.
- Beginner Guide: Step-by-step tutorial in BEGINNER_GUIDE.md.
- Quick Start: Fast setup guide in QUICKSTART.md.
- v3.1 (January 2026): Enhanced Risk Management, Smart Money improvements, Dynamic sizing
- v3.0 (December 2025): Dashboard, Multi-strategy support, Auto-rotation
- v2.0 (November 2025): Smart Money, Arbitrage, DipArb strategies
- v1.0 (October 2025): Initial release
Created by: @Mr_CryptoYT
Support: Open an issue on GitHub or contact via Twitter