An automated trading bot for Polymarket that monitors Bitcoin 15-minute up/down markets and executes buy orders when token prices reach a target threshold. This bot win rate reaches 95%. This is a free version that has simple features, feel free to reach out me[Telegram: https://t.me/trade_SEB] when you need an advanced version.
Clone the repository (if applicable) or navigate to the project directory:
bash
cd /root/Work/Polymarket-Trading-Bot
Install dependencies:
bash
npm install
Build the project:
bash
npm run build
Configure environment variables (see Configuration section below)
Create a .env file in the project root with the following variables:
# Polymarket Authentication
POLYMARKET_PRIVATE_KEY=your_private_key_here
POLYMARKET_PROXY=your_proxy_wallet_address
# OR use PROXY_WALLET_ADDRESS instead of POLYMARKET_PROXY
# Trading Parameters
BOT_TARGET_PRICE=0.95 # Buy when best ask <= this price (default: 0.95)
BOT_MIN_PRICE=0.90 # Optional: only buy when best ask >= this (default: null)
BOT_BUY_SIZE=5 # Number of tokens to buy per order (default: 5)
BOT_DRY_RUN=true # Set to "true" to test without placing orders (default: false)
BOT_PRICE_LOG_INTERVAL_MS=1000 # Log prices every N ms (0 = every update, default: 1000)
# Polymarket API Configuration
POLYMARKET_CLOB_URL=https://clob.polymarket.com
POLYMARKET_CHAIN_ID=137 # Polygon mainnet (default: 137)
POLYMARKET_TICK_SIZE=0.01 # Order price precision: 0.01, 0.001, or 0.0001 (default: 0.01)
POLYMARKET_NEG_RISK=false # Allow negative risk orders (default: false)
POLYMARKET_CREDENTIAL_PATH= # Path to credentials JSON file (optional)
POLYMARKET_SIGNATURE_TYPE=2 # Signature type: 0, 1, or 2 (auto-detected if proxy set)
If using POLYMARKET_CREDENTIAL_PATH, create a JSON file with:
{
"key": "your_api_key",
"secret": "your_api_secret",
"passphrase": "your_passphrase"
}
If not provided, the bot will automatically create/derive API credentials using your private key.
Run the bot directly with TypeScript:
npm run bot
Build and run:
npm run build
npm start
Check TypeScript types without building:
npm run typecheck
Remove compiled files:
npm run clean
The bot automatically detects the current 15-minute Bitcoin up/down market:
- Calculates the current 15-minute slot (00, 15, 30, 45 minutes past the hour)
- Generates market slug: btc-updown-15m-{timestamp}
- Fetches token IDs for "Up" and "Down" tokens from Polymarket Gamma API
book events (full order book)best_bid_ask events (best prices only)price_change events (price updates)When a token's best ask price reaches the target:
- Validates minimum price (if configured)
- Checks if already bought this token in current slot
- Places a limit buy order:
- Order type: GTC (Good Till Cancel)
- Price: min(price + 0.01 buffer, 0.99)
- Size: Configured buy size
- Rounded to tick size precision
Adjust the strategy by modifying environment variables:
- Lower BOT_TARGET_PRICE to buy at lower prices (more aggressive)
- Set BOT_MIN_PRICE to avoid buying when the other side is winning
- Increase BOT_BUY_SIZE for larger positions
- Use BOT_DRY_RUN=true to test without real orders
Polymarket-Trading-Bot/
├── src/
│ ├── btc-15m-high-price-bot.ts # Main bot entry point
│ ├── config.ts # Configuration and env vars
│ └── polymarket/
│ ├── order.ts # Order placement logic
│ ├── prices.ts # Market slug and token ID resolution
│ └── ws-prices.ts # WebSocket client for price updates
├── dist/ # Compiled JavaScript (generated)
├── package.json
├── tsconfig.json
└── README.md
btc-15m-high-price-bot.ts)Handles order triggers and execution
Price Resolution (prices.ts)
Implements caching for performance
WebSocket Client (ws-prices.ts)
Provides real-time price callbacks
Order Placement (order.ts)
npm run build
npm run typecheck
npm run bot
$ claude mcp add polymarket-trading-bot \
-- python -m otcore.mcp_server <graph>