Skip to main content

Polymarket Bot

Real-time BTC price prediction engine for Polymarket 5-minute binary markets using Black-Scholes probability models, EWMA volatility estimation, and momentum-based adjustments

What it does

Monitor live BTC prices, predict binary market outcomes, and identify positive Expected Value opportunities using sophisticated mathematical models

Real-time monitoring

WebSocket feed from Polymarket’s Chainlink oracle for live BTC/USD prices with spike guards and NaN filtering

Mathematical predictions

Black-Scholes binary options combined with EWMA volatility and momentum signals in logit space

Risk management

Fractional Kelly criterion position sizing with 4-level drawdown tracking and cold-streak detection

7-condition abstention

Intelligent system avoids trading when the model has no statistical edge

Model calibration

Platt sigmoid recalibration auto-activates at 200+ samples to correct systematic bias

Comprehensive metrics

Brier Score, Log Loss, Murphy decomposition, runs test, and confidence band analysis

Quick start

Get the bot running in less than 5 minutes

1

Install dependencies

Clone the repository and install packages using your preferred package manager:
git clone https://github.com/joicodev/polymarket-bot.git
cd polymarket-bot
pnpm install
2

Start the prediction engine

Run the bot to begin monitoring BTC prices and generating predictions:
pnpm start
The console will display real-time predictions, model confidence, and interval results.
3

Review predictions and metrics

Watch the live output showing:
  • Current BTC price vs strike price
  • Model prediction with confidence level
  • Expected Value vs market prices
  • Historical accuracy and abstention reasons
Press Ctrl+C to stop the bot gracefully.

How predictions work

The engine combines three mathematical models in logit space for sound probability adjustments

The base probability uses distance to strike, realized volatility, and time remaining:
P(BTC > Strike) = N(d2)
d2 = [ln(S0/K) - (sigma^2/2)*T] / (sigma * sqrt(T))
Where N(d2) is the cumulative standard normal distribution evaluated at d2.
Exponentially weighted moving average of realized volatility with lambda=0.94, normalized to per-second units:
sigma = sqrt(EWMA(r^2 / dt))
Tracks volatility history for anomalous regime detection.
Momentum and mean reversion adjustments applied in log-odds space, then mapped back to probability:
finalProb = sigmoid(logit(baseProb) + w_momentum * ROC + w_reversion * deviation)
This ensures probabilities remain mathematically sound within (0,1) bounds.
The model abstains from trading when it has no edge:
  1. Insufficient data - Less than 50 price ticks
  2. Dead zone - Base probability within 10% of 50%
  3. Anomalous volatility - Sigma exceeds 2x mean
  4. Cold streak - Rolling accuracy below 40%
  5. Insufficient EV - Expected Value below 5%
  6. Insufficient margin - Edge below 15 percentage points
  7. Drawdown suspended - Drawdown at red or critical level

Explore the documentation

Deep dive into the prediction engine, configuration options, and API reference

Core concepts

Understand how the prediction engine works, data sources, and risk management strategies

Configuration

Tune parameters for EWMA lambda, logit weights, abstention thresholds, and risk limits

Prediction engine

Technical reference for Black-Scholes, volatility, momentum, and calibration modules

API reference

Complete API documentation for all public classes and methods

Ready to start predicting?

Follow the quickstart guide to get the prediction engine running on your machine

Get Started