Advanced Polymarket trading bot built in Python, supporting gasless trades, live WebSocket market data, and automated arbitrage and volatility strategies for short-interval prediction markets.
Gmail: [email protected]
Telegram: @SOLBenjaminCup
X : @benjaminccup
-
Gasless Order Execution
Integration with the Polymarket Builder Program for zero-gas trading. -
Real-Time Market Data
Live WebSocket streaming for orderbooks and market state updates. -
15-Minute Market Support
Native support for BTC, ETH, SOL, and XRP markets. -
Strategy Framework
Modular architecture for implementing automated trading strategies. -
Flash Crash Detection
Built-in volatility-based strategy for probability dislocations. -
Secure Key Management
PBKDF2 (480k iterations) + Fernet encrypted private key storage. -
Developer-Friendly API
Clean, extensible Python interface.
git clone https://github.com/Benjamin-cup/Arbitrage-bot-Polymarket.git
cd Arbitrage-bot-Polymarket
pip install -r requirements.txtSet environment variables:
export POLY_PRIVATE_KEY=your_private_key
export POLY_PROXY_WALLET=0xYourPolymarketProxyWalletSafe Address: Find at polymarket.com/settings
python 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)
Real-time orderbook visualization:
python apps/orderbook_viewer.py --coin BTC --levels 5from 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 TradingBot, Config
bot = TradingBot(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: TradingBot(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.
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)
TradingBot: 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()
| 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.
I also developed a trading bot for Polymarket using Rust. If you're interested, please contact me.
Disclaimer: This software is provided for educational and research purposes only. Trading prediction markets involves risk, and no guarantees of profitability are implied. The authors assume no responsibility for financial losses incurred through use of this software.