Documentation Index
Fetch the complete documentation index at: https://mintlify.com/joicodev/polymarket-bot/llms.txt
Use this file to discover all available pages before exploring further.
Architecture
The Polymarket Bot prediction engine combines multiple mathematical models to generate probabilistic forecasts for binary market outcomes. The system operates in real-time on streaming price data and produces calibrated probability estimates.Core Components
The prediction pipeline consists of five interconnected modules:Black-Scholes
Binary option probability from geometric Brownian motion assumptions
Volatility
EWMA estimator producing per-second volatility from tick stream
Momentum
ROC and mean-reversion signals across multiple time windows
Calibration
Platt sigmoid scaling for post-hoc probability refinement
Prediction Flow
1. Data Ingestion
Price ticks are fed into both the volatility estimator and momentum analyzer:2. Base Probability Calculation
The Black-Scholes binary option model produces a base probability using current volatility:Volatility Units: The EWMA estimator produces per-second volatility (σ), matching the time units expected by the Black-Scholes formula.
3. Signal Extraction
Momentum and mean-reversion signals are computed from the tick buffer:4. Logit-Space Fusion
Signals are combined using log-odds arithmetic to preserve probability bounds:5. Platt Calibration
When ≥200 prediction/outcome pairs have been collected, the scaler automatically activates:Abstention Conditions
The engine abstains (refuses to predict) under six conditions:| Condition | Trigger | Reason |
|---|---|---|
| Insufficient Data | σ = 0 or ticks < minTicks | EWMA not warmed up |
| Dead Zone | |p - 0.5| < deadZone | No edge detected |
| Anomalous Regime | σ > sigmaMultiplier × mean(σ) | Volatility spike |
| Cold Streak | Recent accuracy < minAccuracy | Model underperforming |
| Low EV | EV < minEV | Expected value too small (post-prediction filter) |
| Thin Margin | margin < minMargin | Insufficient Kelly bet size (post-prediction filter) |
Conditions 5-6 are implemented as post-prediction filters in
src/index.js because they require market price data external to the model.Near-Expiry Guard
When ≤5 seconds remain until market close, momentum/reversion adjustments are skipped:Mathematical Foundations
Logit Transform
The logit (log-odds) function maps probability space to the real line: Its inverse, the sigmoid (logistic) function:Why Logit-Space Combination?
Probabilities are constrained to [0,1], making naive arithmetic problematic:- Addition: 0.6 + 0.5 = 1.1 (invalid)
- Multiplication: 0.9 × 0.9 = 0.81 (compression bias)
- Adjusted probabilities always ∈ (0,1)
- Symmetric treatment of probabilities near 0 and 1
- Natural interpretation as additive evidence
Implementation Details
Safety Clamping
The logit function is undefined at 0 and 1. Inputs are clamped to [10⁻⁷, 1-10⁻⁷]:Outcome Tracking
The engine maintains a rolling window of recent outcomes for cold-streak detection:State Management
The engine offers two reset modes:Configuration Parameters
Key engine settings fromconfig.js:
Next Steps
Black-Scholes Model
Deep dive into binary option probability calculation
Volatility Estimation
EWMA algorithm and per-second variance normalization
Momentum Signals
ROC windows and mean-reversion detection
Predictor Integration
Complete prediction engine API and usage examples