Production-ready Python trading bot for Polymarket with gasless transactions and real-time WebSocket orderbook streaming.
Repository: https://github.com/crymeer/polymarket-arbitrage-bot
- Gasless Trading - Builder Program integration for zero gas fees
- Real-time WebSocket - Live orderbook updates and market data
- 15-Minute Markets - Built-in support for BTC/ETH/SOL/XRP markets
- Flash Crash Strategy - Pre-built volatility trading strategy
- Secure Storage - PBKDF2 + Fernet encrypted private key storage
- Simple API - Clean, intuitive Python interface
Set environment variables:
export POLY_PRIVATE_KEY=your_private_key
export POLY_PROXY_WALLET=0xYourPolymarketProxyWalletSafe Address: Find at polymarket.com/settings
Windows:
# Interactive menu (best option)
python run.py
# Or use batch files
run_bot.bat # Run trading bot
run_viewer.bat # View orderbook (no trading)
quick_start.bat # Quick start with defaultsLinux/Mac:
python run.py # Interactive menupython apps/flash_crash_runner.py --coin BTCMonitors 15-minute markets for sudden probability drops and executes trades automatically.
# Default settings
python apps/flash_crash_runner.py --coin BTC
# Custom parameters
python apps/flash_crash_runner.py --coin ETH --drop 0.25 --size 10 --take-profit 0.10 --stop-loss 0.05Parameters:
--coin- BTC, ETH, SOL, XRP (default: ETH)--drop- Drop threshold (default: 0.30)--size- Trade size in USDC (default: 5.0)--lookback- Detection window in seconds (default: 10)--take-profit- Take profit in dollars (default: 0.10)--stop-loss- Stop loss in dollars (default: 0.05)--speed- Main loop interval in seconds (default: 0.05 = 50ms). Lower = faster
Real-time orderbook visualization:
# Default (50ms updates)
python apps/orderbook_viewer.py --coin BTC
# Faster scanning (10ms updates)
python apps/orderbook_viewer.py --coin BTC --speed 0.01
# Custom levels
python apps/orderbook_viewer.py --coin BTC --levels 10Parameters:
--coin- BTC, ETH, SOL, XRP (default: ETH)--speed- Update interval in seconds (default: 0.05 = 50ms). Lower = faster scanning--levels- Number of price levels to display (default: 10)
from src import create_bot_from_env
import asyncio
async def main():
bot = create_bot_from_env()
orders = await bot.get_open_orders()
print(f"Open orders: {len(orders)}")
asyncio.run(main())from src import ArbitrageBot, Config
bot = ArbitrageBot(config=Config(safe_address="0x..."), private_key="0x...")
result = await bot.place_order(token_id="...", price=0.65, size=10.0, side="BUY")from src.websocket_client import MarketWebSocket
ws = MarketWebSocket()
ws.on_book = lambda s: print(f"Price: {s.mid_price:.4f}")
await ws.subscribe(["token_id"])
await ws.run()| Variable | Required | Description |
|---|---|---|
POLY_PRIVATE_KEY |
Yes | Wallet private key |
POLY_PROXY_WALLET |
Yes | Polymarket Proxy wallet address |
POLY_BUILDER_API_KEY |
Optional | Builder Program API key (gasless) |
POLY_BUILDER_API_SECRET |
Optional | Builder Program API secret |
POLY_BUILDER_API_PASSPHRASE |
Optional | Builder Program passphrase |
Create config.yaml:
safe_address: "0xYourAddress"
builder:
api_key: "your_key"
api_secret: "your_secret"
api_passphrase: "your_passphrase"Load with: ArbitrageBot(config_path="config.yaml", private_key="0x...")
Enable gasless trading via Builder Program:
- Apply at polymarket.com/settings?tab=builder
- Set environment variables:
POLY_BUILDER_API_KEY,POLY_BUILDER_API_SECRET,POLY_BUILDER_API_PASSPHRASE
The bot automatically uses gasless mode when credentials are present.
polymarket-arbitrage-bot/
├── src/ # Core library
├── strategies/ # Trading strategies
├── apps/ # Application entry points
├── scripts/ # Utility scripts
└── lib/ # Reusable components
Private keys are encrypted using PBKDF2 (480,000 iterations) + Fernet symmetric encryption. Best practices:
- Never commit
.envfiles - Use a dedicated trading wallet
- Keep encrypted key files secure (permissions: 0600)
ArbitrageBot: place_order(), cancel_order(), get_open_orders(), get_trades(), get_order_book(), get_market_price()
MarketWebSocket: subscribe(), run(), disconnect(), get_orderbook(), get_mid_price()
GammaClient: get_market_info(), get_current_15m_market(), get_all_15m_markets()
The bot uses event-driven detection for instant flash crash detection (1-5ms latency). You can further increase speed:
# Ultra-fast (10ms loop - 10x faster than default)
python apps/flash_crash_runner.py --coin BTC --speed 0.01
# Fast (20ms loop - 4x faster)
python apps/flash_crash_runner.py --coin BTC --speed 0.02
# Default (50ms loop - already 2x faster than before)
python apps/flash_crash_runner.py --coin BTCSpeed Settings:
--speed 0.01= 10ms (100 updates/sec) - Ultra-fast--speed 0.02= 20ms (50 updates/sec) - Fast--speed 0.05= 50ms (20 updates/sec) - Default (2x faster)--speed 0.1= 100ms (10 updates/sec) - Slower (old default)
# Ultra-fast scanning (10ms - 100 updates/sec)
python apps/orderbook_viewer.py --coin BTC --speed 0.01
# Fast scanning (20ms - 50 updates/sec)
python apps/orderbook_viewer.py --coin BTC --speed 0.02
# Default (50ms - 20 updates/sec)
python apps/orderbook_viewer.py --coin BTCNote: Flash crash detection is always event-driven (1-5ms latency) regardless of --speed setting. The --speed parameter only affects exit checks (TP/SL monitoring) and display updates.
| Issue | Solution |
|---|---|
| Missing credentials | Set POLY_PRIVATE_KEY and POLY_PROXY_WALLET |
| Invalid private key | Ensure 64 hex characters (0x prefix optional) |
| Order failed | Check sufficient balance |
| WebSocket errors | Verify network/firewall settings |
MIT License - see LICENSE file for details.
High-ROI Polymarket Arbitrage in 2026:
Programmatic Dutch-Book Strategies, Bots, and Portfolio OptimizationDutch-book arbitrage on Polymarket remains a solid edge—buy a complete set of mutually exclusive outcomes for under 1 USDC, guaranteeing profit when one resolves to 1. But in 2026, success hinges on execution, fees, and robustness amid evolved APIs and fiercer competition.

I've also developed a trading bot for Polymarket built with Rust.
https://www.youtube.com/watch?v=4f6jHT4-DQs
Disclaimer: This software is for educational purposes only. Trading involves risk of loss. The developers are not responsible for any financial losses incurred while using this bot.
Support: For questions or issues, contact via Telegram: @vladmeer | Twitter: @vladmeer