DEV Community

FatherSon
FatherSon

Posted on

Polymarket BTC 5-Minute Up/Down Trading Bot: Complete Production Build Guide

This open-source Polymarket trading bot targets the highly liquid 5-minute BTC Up/Down binary markets. It uses real-time Binance technical analysis to snipe in the final seconds of each round, when the outcome is largely decided but token prices haven't fully repriced to near $1.00.

Bot Overview

  • Target: Polymarket’s deterministic BTC 5m Up/Down contracts ("Will BTC close higher or lower than the window open price?").
  • Timing: Sleeps until ~T-10 seconds before round close, then runs a fast TA loop.
  • Edge: Clock-based market discovery + composite weighted signal from 7 indicators, dominated by Window Delta.
  • Modes: Safe (25% bankroll), Aggressive (profits only), Degen (all-in).

Architecture (6 Clean Files)

  • bot.py — Main engine, timing, execution, bankroll.
  • strategy.py — 7-indicator composite scoring.
  • compare_runs.py — Multi-config backtester → Excel output.
  • backtest.py — Historical data fetcher.
  • setup_creds.py — One-time Polymarket credential derivation.
  • auto_claim.py — Playwright-based auto-redeemer.

Dependencies (requirements.txt):

py-clob-client==0.34.5
python-dotenv
requests
playwright
openpyxl
Enter fullscreen mode Exit fullscreen mode

Core Strategy: Weighted Composite Signal

The strategy produces a directional score. Positive = Up, Negative = Down.

Dominant Indicator: Window Delta (weight 5–7)

window_pct = (current_price - window_open) / window_open * 100

if window_pct > 0.10: weight = 7   # Almost certain
elif window_pct > 0.02: weight = 5
...
Enter fullscreen mode Exit fullscreen mode

Supporting Indicators (weights 1–2):

  • Micro Momentum (last 2 candles)
  • Acceleration
  • EMA 9/21 crossover
  • RSI 14 extremes
  • Volume Surge
  • Real-time Tick Trend (2-second polling)

Confidence = min(abs(score) / 7.0, 1.0)

Execution Logic (T-10s Snipe Window)

  • Polls every 2 seconds.
  • Tracks best signal seen.
  • Spike detection (score jump ≥1.5) → immediate fire.
  • Hard deadline at T-5s: use best signal (never skip a round).
  • Primary: FOK Market Buy.
  • Fallback: GTC Limit Buy @ $0.95 (becomes liquidity provider).

Realistic Dry-Run & Backtesting

Uses a delta-based pricing model for simulation:

  • Small delta → ~$0.50–0.55 tokens
  • Strong delta (0.10%+) → $0.80–0.97 tokens

This prevents overly optimistic backtests. The comparison tool tests 27 configurations (9 confidence thresholds × 3 modes).

Key Lessons from the Build

  1. Window Delta is king — Short-term TA is noisy at 5m scale.
  2. T-10s is the sweet spot — Enough certainty, still some edge left.
  3. Always trade by T-5s — Better low-confidence trade than missing the round.
  4. Realistic pricing is critical — Fixed $0.50 assumptions destroy backtest validity.
  5. Polymarket minimums — 5 shares/order matters for small bankrolls.

Setup & Running

  1. Export Polymarket wallet private key.
  2. Run setup_creds.py.
  3. Configure .env.
  4. python bot.py --mode safe --dry-run (test first).

This bot exemplifies a production-grade, clock-synced, TA-driven Polymarket trading bot focused on the most liquid short-duration markets. The full code, backtester, and lessons make it an excellent starting point or reference for any serious builder in 2026.

If you have more questions, please feel free to contact me at any time: https://t.me/FatherSon97


#PolymarketTradingBot #TradingBot #CryptoTradingBot #PolymarketBot #DeFiTrading #BTC5MinuteBot #BuzzerStrategy #PredictionMarkets #DeFiBots #QuantTrading #AutomatedTrading #PolymarketStrategy #CryptoDev #TechnicalAnalysisBot

Top comments (0)