Programmatic trading bot for Polymarket on Polygon mainnet.
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install dependencies
pip install -r requirements-dev.txtpython scripts/generate_wallet.pyThis generates a fresh EOA keypair and writes it to .env. Then:
- Send ~$5 USDC (on Polygon) to the printed address
- Send a small amount of POL for gas
Copy and fill in the template:
cp .env.example .envRequired variables:
POLY_PRIVATE_KEY— hex-encoded private keyPOLY_WALLET_ADDRESS— wallet address
Optional:
POLY_RPC_URL— custom RPC (default:https://polygon-rpc.com)POLY_MAX_ORDER_SIZE_USDC— safety limit (default: 50)
python scripts/check_connection.py# Market discovery
python -m polybot markets list --limit 10
python -m polybot markets search "election"
python -m polybot markets detail <condition_id>
python -m polybot markets orderbook <token_id>
# Wallet
python -m polybot wallet status
python -m polybot wallet balance
# Trading
python -m polybot trade buy <token_id> 10.0 --price 0.45
python -m polybot trade sell <token_id> 5.0 --price 0.60
python -m polybot trade orders
python -m polybot trade cancel <order_id>
# Positions
python -m polybot positions list
python -m polybot positions history# Unit tests (offline, mocked)
pytest tests/unit/ -v
# Integration tests (live read-only APIs)
pytest tests/integration/ -v
# E2E test (real money — requires funded wallet)
pytest tests/e2e/test_buy_sell_flow.py --market-id=<CONDITION_ID> -v -smypy polybot/ --strict