Skip to content

FradleyJ/prediction-exploit

Repository files navigation

Polymarket Binary Arbitrage Bot

A Python implementation of the "gabagool strategy" for guaranteed-profit arbitrage on Polymarket's binary prediction markets.

The Strategy

In binary markets (YES/NO outcomes), the two sides always settle to $1.00 combined:

  • If YES wins → YES pays $1.00, NO pays $0.00
  • If NO wins → NO pays $1.00, YES pays $0.00

The insight: If you can acquire YES + NO shares for less than $1.00 combined, you lock in profit regardless of outcome.

Example

Buy 100 YES @ $0.45 = $45.00
Buy 100 NO  @ $0.48 = $48.00
Total cost: $93.00

At settlement:
- If YES wins: 100 × $1.00 = $100.00 → Profit: $7.00
- If NO wins:  100 × $1.00 = $100.00 → Profit: $7.00

Guaranteed profit: $7.00 (7.5% return)

Why It Works

Short-term markets (especially 15-minute crypto predictions) have wild price swings due to emotions. When people panic-sell one side, prices get mispriced. You don't predict direction—you just buy whichever side is cheap.

Installation

cd polymarket_arb
pip install -r requirements.txt

Usage

Interactive Calculator

Test trades and see how they affect your pair cost:

python cli.py calculator

Run Simulation

See the strategy in action with synthetic data:

python cli.py simulate

List Markets

python cli.py markets --limit 20
python cli.py markets --crypto-15m  # 15-minute markets

Scan for Opportunities

python cli.py scan --min-margin 0.02  # 2% minimum margin

Start Monitoring

python cli.py monitor --duration 900 --interval 2.0

Key Metrics

Metric Description Target
Pair Cost avg(YES price) + avg(NO price) < $1.00
Paired Shares min(YES shares, NO shares) Balanced
Guaranteed Profit Paired shares × (1.00 - Pair Cost) Positive
Exposure YES shares - NO shares Near zero

Project Structure

polymarket_arb/
├── cli.py                 # Command-line interface
├── bot.py                 # Main arbitrage bot
├── core/
│   └── position_tracker.py # Position & P&L tracking
├── api/
│   └── client.py          # Polymarket API client
└── data/                  # Saved positions (auto-created)

Configuration

Edit BotConfig in bot.py:

BotConfig(
    max_capital_per_market=1000,  # Max $ per market
    max_pair_cost=0.98,           # Target 2% margin
    min_arbitrage_margin=0.02,    # Min spread to trade
    poll_interval=2.0,            # Seconds between checks
    dry_run=True,                 # Simulate only
)

Trading Logic

  1. Scan markets for YES + NO < $1.00
  2. Identify which side is cheaper
  3. Simulate trade impact on pair cost
  4. Execute if it improves position
  5. Balance to minimize directional exposure
  6. Repeat until market closes

Important Notes

Risk Management

  • Start with dry_run=True to simulate
  • Use small position sizes initially
  • Monitor for API rate limits
  • Be aware of liquidity constraints

Market Access

  • 15-minute markets may require specific API endpoints
  • Some markets have minimum order sizes
  • Fees can compress margins

Limitations

  • Live trading requires wallet setup and API keys
  • This is a proof-of-concept, not production-ready
  • Past performance doesn't guarantee future results

API Reference

Position Tracker

from core.position_tracker import Position

pos = Position(market_id="btc-up-down", market_name="BTC 15m")
pos.add_trade('YES', quantity=100, price=0.45)
pos.add_trade('NO', quantity=100, price=0.48)

print(pos.pair_cost)         # 0.93
print(pos.guaranteed_profit) # 7.00

Trade Simulation

# Check impact before executing
sim = pos.simulate_trade('YES', 50, 0.40)
print(sim['should_execute'])  # True/False
print(sim['profit_change'])   # Expected profit change

API Client

from api.client import PolymarketClient

client = PolymarketClient()
markets = client.get_markets(active=True, tag_slug='crypto')
price = client.get_market_price(market)
print(price.arbitrage_margin)

Extending

Add Live Trading

Implement execute_trade() in bot.py using the Polymarket CLOB client:

pip install py-clob-client

Add WebSocket Monitoring

For real-time price feeds instead of polling.

Add Database Persistence

Replace JSON state files with SQLite for better history tracking.

Resources

Disclaimer

This software is for educational purposes. Trading involves risk of loss. Do your own research and never trade more than you can afford to lose.

About

Polymarket binary arbitrage bot exploiting guaranteed-profit YES+NO mispricings

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages