Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ env/
.coverage
coverage.xml
htmlcov/
help
project_source_dump.txt

# IDE / OS files
.vscode/
Expand Down
154 changes: 90 additions & 64 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,95 @@
# Polymarket Bot | Polymarket Trading Bot | Polymarket Arbitrage Bot
# Polymarket Bot: Automated Trading & Arbitrage System

Polymarket Bot, Polymarket Trading Bot, Polymarket Arbitrage Bot, Polymarket Automatic Trading Bot
Advanced Polymarket Trading Bot (Python) – A high-performance automated trading system for Polymarket prediction markets, built in Python. Supports gasless trading, real-time WebSocket market data streaming, and fully automated arbitrage and volatility strategies optimized for short-term and high-frequency trading environments. Designed for efficient capital allocation, low-latency execution, and scalable quantitative crypto trading.
An advanced Python trading bot for Polymarket prediction markets. This system provides high-performance automation, including gasless trading, real-time WebSocket market data, and sophisticated arbitrage and volatility strategies. Designed for efficient capital allocation, low-latency execution, and scalable quantitative crypto trading in active and high-frequency environments.

Status: Live trading enabled. Dashboard available at configured domain.
**Status:** Live trading enabled. Dashboard available at your configured domain.

Read article here: https://medium.com/@benjamin.bigdev/high-roi-polymarket-arbitrage-in-2026-programmatic-dutch-book-strategies-bots-and-portfolio-41372221bb79
_Read the [Medium article](https://medium.com/@benjamin.bigdev/high-roi-polymarket-arbitrage-in-2026-programmatic-dutch-book-strategies-bots-and-portfolio-41372221bb79) for more insight._

---

## Contact info
## Table of Contents
1. [Contact](#contact)
2. [Demo Video](#demo-video)
3. [Strategy Overview](#strategy-overview)
- [Directional/Speculative Strategy](#directionalspeculative-strategy)
- [Pure Arbitrage](#pure-arbitrage)
4. [Status](#status)
5. [Features](#features)
6. [Setup](#setup)
7. [Configuration](#configuration)
8. [Contract Approvals](#contract-approvals)
9. [Geo-Restrictions & Proxy Setup](#geo-restrictions--proxy-setup)
10. [Documentation](#documentation)
11. [License](#license)

Gmail: benjamin.bigdev@gmail.com
---

Telegram: [@BenjaminCup](https://t.me/BenjaminCup)
## Contact

X : [@benjaminccup](https://x.com/benjaminccup)
- Telegram: [@BenjaminCup](https://t.me/BenjaminCup)

---

## Video
## Demo Video

https://github.com/user-attachments/assets/f06d66ee-4408-4076-91c3-5476d780cf7a

## Strategy
---

Core Steps (Binary Yes/No market):
## Strategy Overview

Identify a directional conviction (“Yes” or “No” is undervalued).
Execute a sizable buy of the favored outcome when its price is around $0.60 (opposite side therefore ~$0.40). In thin order books this visibly moves the favored price to $0.61–$0.62 and the opposite to $0.38–$0.39.
Rely on other participants observing the price action (and possibly your on-chain wallet activity) to interpret it as strong conviction → retail/FOMO buying pushes the favored outcome to ~$0.70 and the opposite to ~$0.30.
At the widened spread, buy the now-cheap opposite outcome at ~$0.30.
Claimed P&L: $0.10 gross per share equivalent (difference created by the spread widening you helped engineer) minus ~$0.03 in assumed fees/gas → net ~$0.07 per unit.
### Directional/Speculative Strategy (Binary Yes/No Markets)
1. **Formulate a Directional Conviction:** Identify if "Yes" or "No" is undervalued.
2. **Initiate Position:** Buy the favored outcome when near $0.60. In thin books, this moves the price to ~$0.61–$0.62.
3. **Market Impact:** Others interpret this as strong conviction; retail/FOMO may push the price to ~$0.70.
4. **Counter-Trade:** Buy the now-cheap opposite outcome (~$0.30).
5. **Profit Potential:** ~$0.10 gross per share less estimated $0.03 fees/gas, netting ~$0.07/unit.

This is not arbitrage. It is a speculative momentum + mean-reversion hybrid that attempts to influence short-term order flow.

Strategy is Not for sale but going to share it to customers.

Pure arbitrage: when YES + NO token prices sum to less than $1.00, buy both. One token always pays out $1.00, guaranteeing profit regardless of outcome.
*Note: This is a speculative momentum/mean-reversion approach, not pure arbitrage. The core strategy is not for public sale but may be shared with customers.*

### Pure Arbitrage
When YES + NO token prices sum to under $1.00, purchase both:
```
Example:
YES @ $0.48 + NO @ $0.49 = $0.97 cost
Payout = $1.00 (guaranteed)
Guaranteed payout = $1.00
Profit = $0.03 per dollar (3.09%)
```

---

## Status

Live trading enabled. Dashboard available at configured domain.
- Live trading enabled
- Dashboard accessible via your configured domain

---

## Features

- Real-time WebSocket price monitoring (6 parallel connections, up to 1500 markets)
- Automatic arbitrage detection and execution
- **Low-latency async order execution** (native async HTTP with HTTP/2, parallel order signing)
- Order monitoring with 10-second timeout and auto-cancellation
- Market filtering by liquidity ($10k+ default) and resolution date (7 days default)
- Web dashboard with live order visibility (HTTPS with auto SSL)
- Slack notifications for trades
- SOCKS5 proxy support for geo-restricted order placement
- Real-time WebSocket price monitoring (6 parallel connections, covers up to 1500 markets)
- Automatic arbitrage detection & execution
- **Low-latency async order execution** (native async HTTP/2, parallel signing)
- Order monitoring with 10s timeout & auto-cancel
- Market filtering: by liquidity (default $10k+) and event resolution (default 7 days)
- Web dashboard with live visibility (HTTPS, auto SSL)
- Slack trades notifications
- SOCKS5 proxy support for geo-restricted execution

---

## Setup

```bash
# Clone
# Clone repo
git clone https://github.com/VectorPulser/polymarket-trading-bot.git
cd rarb

# Install dependencies
pip install -e .

# Configure
# Configure environment
cp .env.example .env
# Edit .env with your settings

Expand All @@ -83,83 +104,88 @@ print(f'POLY_API_SECRET={creds.api_secret}')
print(f'POLY_API_PASSPHRASE={creds.api_passphrase}')
"

# Approve Polymarket contracts (one-time setup)
# Approve contracts (one-time)
python scripts/approve_usdc.py

# Run
# Run bot
rarb run --live --realtime
```

---

## Configuration

Required environment variables:
Key environment variables in `.env`:

```bash
# Wallet
PRIVATE_KEY=0x... # Your wallet private key
WALLET_ADDRESS=0x... # Your wallet address
PRIVATE_KEY=0x... # Your wallet private key
WALLET_ADDRESS=0x... # Your wallet address

# Polymarket L2 API Credentials (generate with script above)
# Polymarket L2 API Credentials (see setup)
POLY_API_KEY=...
POLY_API_SECRET=...
POLY_API_PASSPHRASE=...

# Trading Parameters
MIN_PROFIT_THRESHOLD=0.005 # 0.5% minimum profit
MAX_POSITION_SIZE=100 # Max $100 per trade
MIN_LIQUIDITY_USD=10000 # $10k minimum market liquidity
MAX_DAYS_UNTIL_RESOLUTION=7 # Skip markets resolving later
NUM_WS_CONNECTIONS=6 # WebSocket connections (250 markets each)
DRY_RUN=true # Set to false for live trading
# Trading parameters
MIN_PROFIT_THRESHOLD=0.005 # 0.5% min profit
MAX_POSITION_SIZE=100 # $100 max per trade
MIN_LIQUIDITY_USD=10000 # $10k min market liquidity
MAX_DAYS_UNTIL_RESOLUTION=7 # Ignore long-resolving markets
NUM_WS_CONNECTIONS=6 # WebSockets (250 markets ea)
DRY_RUN=true # Set false to enable live trading

# Dashboard (optional - omit for no auth)
# Dashboard (optional)
DASHBOARD_USERNAME=admin
DASHBOARD_PASSWORD=...
```
Refer to `.env.example` for a complete list of options.

See `.env.example` for all available options.
---

## Contract Approvals

Before trading, you must approve Polymarket's smart contracts to spend your USDC.e:
Prior to trading, allow Polymarket contracts to spend your USDC.e:

```bash
# Run the approval script (requires PRIVATE_KEY in environment)
# Requires PRIVATE_KEY set in your environment
python scripts/approve_usdc.py
```

This approves:
Approves:
- CTF Exchange
- Neg Risk Exchange
- Conditional Tokens
- Neg Risk Adapter

## Geo-Restrictions
---

Polymarket blocks US IP addresses for order placement. The recommended architecture:
## Geo-Restrictions & Proxy Setup

- **Bot server (us-east-1)**: Low-latency WebSocket connection for price monitoring
- **Proxy server (ca-central-1 Montreal)**: SOCKS5 proxy for order placement
U.S. IPs are blocked for order placement. Recommended:
- **Bot server (us-east-1):** For fast WebSocket data
- **Proxy server (ca-central-1 Montréal):** SOCKS5 proxy for order routing

Configure the proxy in your `.env`:
Configure your proxy in `.env`:
```bash
SOCKS5_PROXY_HOST=your-proxy-ip
SOCKS5_PROXY_PORT=1080
SOCKS5_PROXY_USER=rarb
SOCKS5_PROXY_PASS=your-password
```
Deployment scripts: see `infra/` (OpenTofu + Ansible).

See `infra/` for OpenTofu + Ansible deployment scripts.


---

## Documentation

See [PRD.md](PRD.md) for full product requirements and technical architecture.
For product requirements and technical architecture, see [PRD.md](PRD.md).

## License
---

MIT
## License

This project is licensed under the MIT License.

---

Let me know if you need further refinement or a different format!
Loading