ugm616/bitgrab

0

stars

2

commits

Python

primary language

Jul 12, 2026

updated

README

BitGrab - Automated Polymarket 5-min Crypto Trading Bot

A production-ready automated trading system for Polymarket's 5-minute BTC/ETH/SOL Up/Down markets. Features realistic simulation mode, SNIPE strategy (late-window entries), arbitrage detection, and ML ensemble predictions.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        VPS (Docker)                              │
├─────────────────────────────────────────────────────────────────┤
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐  │
│  │   Data       │  │   Strategy   │  │   Simulation         │  │
│  │   Feeds      │──▶│   Engine     │──▶│   Engine             │  │
│  │              │  │              │  │                      │  │
│  │ - CLOB WS    │  │ - SNIPE      │  │ - Realistic fills    │  │
│  │ - Binance WS │  │ - ARB        │  │ - Slippage/fees/gas  │  │
│  │ - Gamma API  │  │ - ML Filter  │  │ - PnL tracking       │  │
│  └──────────────┘  └──────────────┘  └──────────────────────┘  │
│         │                 │                     │               │
│         ▼                 ▼                     ▼               │
│  ┌──────────────────────────────────────────────────────────┐  │
│  │              ML Ensemble Predictor                        │  │
│  │  LightGBM + Kronos-mini (AAAI'26) + LLM Sentiment         │  │
│  └──────────────────────────────────────────────────────────┘  │
│                              │                                  │
│                              ▼                                  │
│  ┌──────────────────────────────────────────────────────────┐  │
│  │              Dashboard / API (Port 8080)                  │  │
│  │  - Real-time PnL, positions, trades                      │  │
│  │  - WebSocket live updates                                 │  │
│  │  - Prometheus metrics (Port 9090)                        │  │
│  └──────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Features

Core Strategies

  • SNIPE: Enter final 60→1s of 5-min window when leading side ≥ 0.93 and spot confirms direction
  • Arbitrage: Risk-free when YES + NO < 0.985, buy both sides for guaranteed profit
  • ML Filter: LightGBM + Kronos foundation model + LLM sentiment ensemble

Risk Management

  • Daily loss limit, daily volume cap
  • Max concurrent positions, position size limits
  • Loss streak circuit breaker (pause after N losses)
  • Kelly criterion position sizing
  • Reactive hedging on adverse moves

Simulation Mode (Default)

  • Configurable fill probability, slippage (bps), taker fees, Polygon gas (~$0.01)
  • Partial fills, order expiration
  • Full P&L tracking with SQLite persistence

Quick Deploy

Prerequisites

  • VPS with 2GB+ RAM (Oracle Cloud Free Tier recommended: 24GB RAM free forever)
  • Docker + Docker Compose installed
  • Polygon RPC endpoint (public works: https://polygon-rpc.com)

One-Command Deploy

# Clone and deploy
git clone <your-repo-url> bitgrab
cd bitgrab
chmod +x deploy.sh
./deploy.sh

The deploy script will:

  1. Install Docker + Compose if missing
  2. Create .env from template (prompts for required values)
  3. Build and start containers (bot + Redis + Prometheus)
  4. Show dashboard URL and status

Manual Deploy

# 1. Install Docker
curl -fsSL https://get.docker.com | sh
apt-get install -y docker-compose-plugin

# 2. Configure
cp .env.example .env
# Edit .env with your values

# 3. Deploy
docker compose up -d --build

# 4. Verify
docker compose logs -f bitgrab

Configuration

Edit .env with your settings:

# Required
POLYGON_RPC_URL=https://polygon-rpc.com

# Simulation (paper trading)
SIMULATION_MODE=true
SIMULATION_INITIAL_BANKROLL=1000
SIMULATION_POSITION_SIZE_USDC=25
SIMULATION_MAX_DAILY_LOSS_USDC=100
SIMULATION_MAX_DAILY_VOLUME_USDC=2000
SIMULATION_LOSS_STREAK_PAUSE=3

# SNIPE Strategy
SNIPE_MIN_PRICE=0.93
SNIPE_MAX_PRICE=0.995
SNIPE_ENTRY_START_SECS=60
SNIPE_ENTRY_END_SECS=1
SNIPE_HEDGE_RATIO=0.30
SNIPE_REACTIVE_HEDGE_ENABLED=true
SNIPE_REACTIVE_HEDGE_TRIGGER_BPS=800
SNIPE_ARB_ENABLED=true
SNIPE_ARB_THRESHOLD_BPS=150

# ML
ML_ENABLED=true
ML_MODEL_PATH=./models/snipe_model.onnx
ML_CONFIDENCE_THRESHOLD=0.55
ML_KELLY_FRACTION=0.5

# Optional: LLM Sentiment (OpenRouter free tier)
OPENROUTER_API_KEY=

# Dashboard
DASHBOARD_PORT=8080

Access Points

ServiceURLDescription
Dashboardhttp://<VPS_IP>:8080Real-time PnL, positions, trades
Metricshttp://<VPS_IP>:9090Prometheus metrics
Healthhttp://<VPS_IP>:8080/api/statusJSON bot status

Paper → Live Graduation

Only go live after:

  • 100+ settled trades in simulation
  • Win rate ≥ 65%
  • Positive EV per trade
  • Max drawdown < 10%

Then:

  1. Set SIMULATION_MODE=false in .env
  2. Add wallet credentials:
    POLYGON_PRIVATE_KEY=0x...
    POLYMARKET_FUNDER_ADDRESS=0x...
    POLYMARKET_SIGNATURE_TYPE=2
    POLYMARKET_API_KEY=...
    POLYMARKET_API_SECRET=...
    POLYMARKET_API_PASSPHRASE=...
    
  3. Start with $2 position size (Phase 1)
  4. Scale per config gates only after metrics

Project Structure

bitgrab/
├── deploy.sh              # One-command deployment
├── docker-compose.yml     # Bot + Redis + Prometheus
├── Dockerfile             # Main bot container
├── Dockerfile.dashboard   # Dashboard container
├── prometheus.yml         # Metrics config
├── .env.example           # Config template
├── README.md
├── pyproject.toml
├── requirements.txt
└── src/
    ├── __init__.py
    ├── config.py          # Pydantic settings
    ├── models.py          # Data models
    ├── data_feeds.py      # CLOB WS, Binance WS, Gamma API
    ├── simulation.py      # Realistic sim engine
    ├── strategies.py      # SNIPE, ARB, RiskManager
    ├── ml_models.py       # LightGBM + Kronos + LLM
    ├── features.py        # 30+ technical indicators
    ├── dashboard.py       # aiohttp + WebSocket UI
    ├── main.py            # Main orchestrator
    └── bot.py             # Legacy entry

Monitoring

# View logs
docker compose logs -f bitgrab

# Check status
docker compose ps

# Restart
docker compose restart bitgrab

# Update
git pull && docker compose up -d --build

Dashboard Features

  • Real-time PnL: Bankroll, daily/total P&L, ROI, win rate
  • Open Positions: Entry price, size, unrealized P&L, fees
  • Trade History: Last 100 fills with timestamps
  • Live Updates: WebSocket pushes every 5s
  • Controls: Pause/resume/close-all via API

Prometheus Metrics

  • bitgrab_bankroll_usdc - Current bankroll
  • bitgrab_total_pnl_usdc - Cumulative P&L
  • bitgrab_daily_pnl_usdc - Today's P&L
  • bitgrab_win_rate - Winning trade %
  • bitgrab_open_positions - Active positions
  • bitgrab_cycles_total - Trading cycles completed

Disclaimer

Educational/research software. Prediction markets involve substantial financial risk. Past performance ≠ future results. Test thoroughly in simulation before any live capital. Not financial advice.

License

MIT

Contributors

ugm616

2 commits

ugm616/bitgrab

0

stars

2

commits

Python

primary language

Jul 12, 2026

updated

README

BitGrab - Automated Polymarket 5-min Crypto Trading Bot

A production-ready automated trading system for Polymarket's 5-minute BTC/ETH/SOL Up/Down markets. Features realistic simulation mode, SNIPE strategy (late-window entries), arbitrage detection, and ML ensemble predictions.

Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        VPS (Docker)                              │
├─────────────────────────────────────────────────────────────────┤
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────────────┐  │
│  │   Data       │  │   Strategy   │  │   Simulation         │  │
│  │   Feeds      │──▶│   Engine     │──▶│   Engine             │  │
│  │              │  │              │  │                      │  │
│  │ - CLOB WS    │  │ - SNIPE      │  │ - Realistic fills    │  │
│  │ - Binance WS │  │ - ARB        │  │ - Slippage/fees/gas  │  │
│  │ - Gamma API  │  │ - ML Filter  │  │ - PnL tracking       │  │
│  └──────────────┘  └──────────────┘  └──────────────────────┘  │
│         │                 │                     │               │
│         ▼                 ▼                     ▼               │
│  ┌──────────────────────────────────────────────────────────┐  │
│  │              ML Ensemble Predictor                        │  │
│  │  LightGBM + Kronos-mini (AAAI'26) + LLM Sentiment         │  │
│  └──────────────────────────────────────────────────────────┘  │
│                              │                                  │
│                              ▼                                  │
│  ┌──────────────────────────────────────────────────────────┐  │
│  │              Dashboard / API (Port 8080)                  │  │
│  │  - Real-time PnL, positions, trades                      │  │
│  │  - WebSocket live updates                                 │  │
│  │  - Prometheus metrics (Port 9090)                        │  │
│  └──────────────────────────────────────────────────────────┘  │
└─────────────────────────────────────────────────────────────────┘

Features

Core Strategies

  • SNIPE: Enter final 60→1s of 5-min window when leading side ≥ 0.93 and spot confirms direction
  • Arbitrage: Risk-free when YES + NO < 0.985, buy both sides for guaranteed profit
  • ML Filter: LightGBM + Kronos foundation model + LLM sentiment ensemble

Risk Management

  • Daily loss limit, daily volume cap
  • Max concurrent positions, position size limits
  • Loss streak circuit breaker (pause after N losses)
  • Kelly criterion position sizing
  • Reactive hedging on adverse moves

Simulation Mode (Default)

  • Configurable fill probability, slippage (bps), taker fees, Polygon gas (~$0.01)
  • Partial fills, order expiration
  • Full P&L tracking with SQLite persistence

Quick Deploy

Prerequisites

  • VPS with 2GB+ RAM (Oracle Cloud Free Tier recommended: 24GB RAM free forever)
  • Docker + Docker Compose installed
  • Polygon RPC endpoint (public works: https://polygon-rpc.com)

One-Command Deploy

# Clone and deploy
git clone <your-repo-url> bitgrab
cd bitgrab
chmod +x deploy.sh
./deploy.sh

The deploy script will:

  1. Install Docker + Compose if missing
  2. Create .env from template (prompts for required values)
  3. Build and start containers (bot + Redis + Prometheus)
  4. Show dashboard URL and status

Manual Deploy

# 1. Install Docker
curl -fsSL https://get.docker.com | sh
apt-get install -y docker-compose-plugin

# 2. Configure
cp .env.example .env
# Edit .env with your values

# 3. Deploy
docker compose up -d --build

# 4. Verify
docker compose logs -f bitgrab

Configuration

Edit .env with your settings:

# Required
POLYGON_RPC_URL=https://polygon-rpc.com

# Simulation (paper trading)
SIMULATION_MODE=true
SIMULATION_INITIAL_BANKROLL=1000
SIMULATION_POSITION_SIZE_USDC=25
SIMULATION_MAX_DAILY_LOSS_USDC=100
SIMULATION_MAX_DAILY_VOLUME_USDC=2000
SIMULATION_LOSS_STREAK_PAUSE=3

# SNIPE Strategy
SNIPE_MIN_PRICE=0.93
SNIPE_MAX_PRICE=0.995
SNIPE_ENTRY_START_SECS=60
SNIPE_ENTRY_END_SECS=1
SNIPE_HEDGE_RATIO=0.30
SNIPE_REACTIVE_HEDGE_ENABLED=true
SNIPE_REACTIVE_HEDGE_TRIGGER_BPS=800
SNIPE_ARB_ENABLED=true
SNIPE_ARB_THRESHOLD_BPS=150

# ML
ML_ENABLED=true
ML_MODEL_PATH=./models/snipe_model.onnx
ML_CONFIDENCE_THRESHOLD=0.55
ML_KELLY_FRACTION=0.5

# Optional: LLM Sentiment (OpenRouter free tier)
OPENROUTER_API_KEY=

# Dashboard
DASHBOARD_PORT=8080

Access Points

ServiceURLDescription
Dashboardhttp://<VPS_IP>:8080Real-time PnL, positions, trades
Metricshttp://<VPS_IP>:9090Prometheus metrics
Healthhttp://<VPS_IP>:8080/api/statusJSON bot status

Paper → Live Graduation

Only go live after:

  • 100+ settled trades in simulation
  • Win rate ≥ 65%
  • Positive EV per trade
  • Max drawdown < 10%

Then:

  1. Set SIMULATION_MODE=false in .env
  2. Add wallet credentials:
    POLYGON_PRIVATE_KEY=0x...
    POLYMARKET_FUNDER_ADDRESS=0x...
    POLYMARKET_SIGNATURE_TYPE=2
    POLYMARKET_API_KEY=...
    POLYMARKET_API_SECRET=...
    POLYMARKET_API_PASSPHRASE=...
    
  3. Start with $2 position size (Phase 1)
  4. Scale per config gates only after metrics

Project Structure

bitgrab/
├── deploy.sh              # One-command deployment
├── docker-compose.yml     # Bot + Redis + Prometheus
├── Dockerfile             # Main bot container
├── Dockerfile.dashboard   # Dashboard container
├── prometheus.yml         # Metrics config
├── .env.example           # Config template
├── README.md
├── pyproject.toml
├── requirements.txt
└── src/
    ├── __init__.py
    ├── config.py          # Pydantic settings
    ├── models.py          # Data models
    ├── data_feeds.py      # CLOB WS, Binance WS, Gamma API
    ├── simulation.py      # Realistic sim engine
    ├── strategies.py      # SNIPE, ARB, RiskManager
    ├── ml_models.py       # LightGBM + Kronos + LLM
    ├── features.py        # 30+ technical indicators
    ├── dashboard.py       # aiohttp + WebSocket UI
    ├── main.py            # Main orchestrator
    └── bot.py             # Legacy entry

Monitoring

# View logs
docker compose logs -f bitgrab

# Check status
docker compose ps

# Restart
docker compose restart bitgrab

# Update
git pull && docker compose up -d --build

Dashboard Features

  • Real-time PnL: Bankroll, daily/total P&L, ROI, win rate
  • Open Positions: Entry price, size, unrealized P&L, fees
  • Trade History: Last 100 fills with timestamps
  • Live Updates: WebSocket pushes every 5s
  • Controls: Pause/resume/close-all via API

Prometheus Metrics

  • bitgrab_bankroll_usdc - Current bankroll
  • bitgrab_total_pnl_usdc - Cumulative P&L
  • bitgrab_daily_pnl_usdc - Today's P&L
  • bitgrab_win_rate - Winning trade %
  • bitgrab_open_positions - Active positions
  • bitgrab_cycles_total - Trading cycles completed

Disclaimer

Educational/research software. Prediction markets involve substantial financial risk. Past performance ≠ future results. Test thoroughly in simulation before any live capital. Not financial advice.

License

MIT

Contributors

ugm616

2 commits

Languages

Python

66.7%

HTML

28.6%

Shell

4.1%