Noureddine RAMDI / A Python bot for safe mean-reversion trading on Polymarket with triple-gate live trading safety

Created Mon, 04 May 2026 10:23:01 +0000 Modified Sat, 23 May 2026 20:41:27 +0000

sterlingcrispin/nothing-ever-happens

Trading prediction markets programmatically is a niche but fascinating challenge, especially when real money is on the line. The Polymarket mean-reversion bot by sterlingcrispin takes a pragmatic approach to automating trades on standalone non-sports binary markets by buying ‘No’ shares when prices hit a configurable cap. What sets this bot apart is its triple-gate live trading safety mechanism — three independent environment variables must all be explicitly set to enable live order execution. If any is missing, the bot defaults to a paper trading mode, effectively eliminating accidental live trades.

what the polymarket mean-reversion bot does

This project is an async Python trading bot designed specifically for Polymarket’s binary prediction markets that are non-sports related. The core strategy is a mean-reversion play: the bot scans markets continuously, identifies opportunities where ‘No’ shares are priced below a configured maximum, then places buy orders in hopes that the price will revert upwards.

Under the hood, the bot is built with Python’s async features to handle market scanning and state management concurrently without blocking. It persists open positions and recovery state to a database to ensure continuity across restarts or failures.

A notable architectural component is its safety-first design, which includes a web dashboard for monitoring, utility scripts for log parsing and database inspection, and Heroku deployment helpers to ease hosting.

The stack includes:

  • Python async programming
  • A database backend for state persistence
  • A web dashboard (likely lightweight, given the scope)
  • Utility scripts and Heroku deployment support

The bot focuses solely on non-sports binary markets, aligning with a specific strategy and avoiding dilution of logic by trying to cover all market types.

why the triple-gate safety model matters

Trading bots handling real money need rigorous safety checks to prevent costly mistakes. This bot’s standout feature is its triple-gate environment variable check:

if (os.environ.get('BOT_MODE') == 'live' and
    os.environ.get('LIVE_TRADING_ENABLED') == 'true' and
    os.environ.get('DRY_RUN') == 'false'):
    # proceed with live trading
else:
    # fallback to paper trading

All three variables must be explicitly set for live order transmission. This pattern is surprisingly clean and effective, preventing accidental live trades due to missing or misconfigured environment variables.

The tradeoff is that it requires explicit configuration and may feel verbose, but the safety benefits outweigh the minor inconvenience.

Beyond safety, the bot uses async market scanning to stay responsive and efficient, allowing it to monitor multiple markets without blocking.

The stateful recovery feature is also crucial — open positions and bot status are persisted so that crashes or restarts don’t lead to orphaned trades or lost state.

Code quality appears solid with pytest tests covering unit and regression cases, which is important for a bot that manipulates real funds.

Limitations include a narrow focus on Polymarket’s non-sports binaries and a mean-reversion-only strategy. This makes it opinionated and less flexible than multi-strategy bots but easier to reason about and maintain.

explore the project

The repo includes a clear setup section with these commands:

pip install -r requirements.txt
cp config.example.json config.json
cp .env.example .env

The config.json file is intentionally local and ignored by git, encouraging users to configure their environment without risking secrets in source control.

Since no explicit quickstart commands for running the bot are provided, the next step is to explore the main bot logic and documentation in the repo. Key resources to check:

  • The main async bot script(s) that implement the scanning and trading logic
  • The web dashboard source and how it interfaces with the trading engine
  • Utility scripts for inspecting the database and parsing logs
  • Tests folder to understand coverage and quality

The .env file and config.json contain crucial parameters to tailor the bot’s behavior, including the triple-gate environment variables.

The Heroku deployment helpers suggest the bot is designed for cloud hosting, making it easier to run continuously.

verdict

This Polymarket mean-reversion bot is a solid example of a niche, safety-conscious trading automation project. Its triple-gate environment variable safety pattern is worth a look for anyone building real-money bots — it sharply reduces the risk of accidental live trading.

It’s not a plug-and-play multi-strategy powerhouse but a focused, well-implemented bot for a particular market and strategy. The async design and stateful recovery show a practical approach to robustness.

If you work with prediction markets or want to study a clean, safety-first approach to live trading bots, this repo offers valuable insights. For general trading automation, expect to invest effort customizing or extending it.

Overall, sterlingcrispin’s bot demonstrates thoughtful engineering where safety and maintainability take precedence over complexity or breadth. That tradeoff is worth understanding for anyone automating real-money trades.


→ GitHub Repo: sterlingcrispin/nothing-ever-happens ⭐ 934 · Python