Skip to main content
The Polymarket Bot uses a centralized JSON configuration system located in config/default.json. All configuration parameters are loaded at runtime via src/config.js.

Configuration Structure

The configuration is organized into six top-level groups:
  • engine — Prediction model parameters (EWMA, momentum, abstention rules)
  • feeds — Data source configuration (Chainlink, Polymarket APIs)
  • storage — Data persistence paths
  • bot — Main loop timing
  • risk — Position sizing and risk management

Engine Configuration

The engine group controls the prediction model’s behavior, including volatility estimation, momentum analysis, abstention logic, and probability calculation.

EWMA Volatility

Exponentially weighted moving average volatility estimator parameters.
engine.ewma.lambda
number
default:"0.94"
Decay factor for EWMA volatility calculation. Higher values (closer to 1.0) give more weight to recent observations.Range: 0.0 - 1.0
Recommended: 0.90 - 0.96
Used in src/engine/volatility.js to compute exponentially weighted realized volatility:
this._variance = lambda * this._variance + (1 - lambda) * (r * r) / dt
Tuning lambda: Start with 0.94. Increase to 0.96 for smoother volatility that reacts slower to price shocks. Decrease to 0.90-0.92 for faster adaptation in volatile markets.

Momentum

Momentum analyzer configuration for rate-of-change and mean reversion signals.
engine.momentum.bufferSize
number
default:"300"
Maximum number of ticks stored in the momentum buffer. Controls the lookback window for ROC and mean reversion calculations.Range: 100 - 500
Recommended: 250 - 350
Larger buffers capture longer-term trends but use more memory. At 1 tick/second, 300 ticks = 5 minutes of data.

Abstention

The 7-condition abstention system prevents trading when the model has no edge.
engine.abstention.minTicks
number
default:"50"
Minimum number of price ticks required before making predictions.Abstention condition 1: Insufficient dataPrevents predictions before the EWMA volatility estimator has enough samples. See src/engine/predictor.js:83.
engine.abstention.deadZone
number
default:"0.10"
Threshold for near-50% base probabilities. If |baseProb - 0.5| < deadZone, abstain.Abstention condition 2: Dead zonePrevents trading when Black-Scholes base probability is too close to 50% (no directional edge).Range: 0.05 - 0.15
Example: With deadZone=0.10, abstain if base probability is between 40% and 60%.
engine.abstention.sigmaMultiplier
number
default:"2.0"
Anomalous volatility threshold as a multiple of mean volatility.Abstention condition 3: Anomalous regimeIf currentSigma > sigmaMultiplier * meanSigma, the market is in an unusual regime and the model abstains.Range: 1.5 - 3.0
Recommended: 2.0 - 2.5
Setting sigmaMultiplier too high (>3.0) may allow trading during flash crashes or major news events when model assumptions break down.
engine.abstention.minAccuracy
number
default:"0.40"
Minimum accuracy threshold for the rolling window.Abstention condition 4: Cold streakIf accuracy over the last minAccuracyWindow predictions drops below this threshold, suspend trading.Range: 0.35 - 0.50
Default: 0.40 (40% accuracy)
engine.abstention.minAccuracyWindow
number
default:"20"
Number of recent predictions to evaluate for cold streak detection.Works with minAccuracy to implement condition 4. See src/engine/predictor.js:109.Range: 15 - 30
Recommended: 20
engine.abstention.minEV
number
default:"0.05"
Minimum expected value required to place a bet.Abstention condition 5: Insufficient EVIf EV = (p/q - 1) < minEV, abstain. Enforced in src/index.js after fetching market price q.Range: 0.03 - 0.10
Example: minEV=0.05 means require at least +5% expected value per dollar wagered.
engine.abstention.minMargin
number
default:"0.15"
Minimum edge (in percentage points) between model probability p and market probability q.Abstention condition 6: Insufficient marginIf |p - q| < minMargin, abstain. Prevents trading on small edges that may be within model noise.Range: 0.10 - 0.20
Example: minMargin=0.15 requires at least 15pp edge (e.g., p=80%, q=65%).
Tuning abstention: Start with defaults. If you see too many losing trades, increase minEV and minMargin. If you’re missing good opportunities, decrease deadZone or minMargin.

Prediction

Core prediction engine parameters for logit-space probability combination.
engine.prediction.fallbackUp
number
default:"0.65"
Fallback probability when prediction fails (directional bias: UP).Range: 0.50 - 0.70
Note: Rarely used in production. Exists for graceful degradation.
engine.prediction.fallbackDown
number
default:"0.35"
Fallback probability when prediction fails (directional bias: DOWN).Must satisfy: fallbackDown = 1 - fallbackUp
engine.prediction.logitMomentumWeight
number
default:"150"
Weight applied to momentum factor in logit space.Critical tuning parameter. Controls how much momentum ROC influences the final prediction.Used in src/engine/predictor.js:130:
const logitAdj = logit(baseProb) 
  + logitMomentumWeight * momentumFactor
  + logitReversionWeight * reversionFactor
Range: 50 - 300
Recommended: 120 - 180
engine.prediction.logitReversionWeight
number
default:"80"
Weight applied to mean reversion factor in logit space.Critical tuning parameter. Controls how much mean reversion influences the final prediction.Range: 40 - 150
Recommended: 60 - 100
Momentum vs Reversion tradeoff: If logitMomentumWeight is too high relative to logitReversionWeight, the model will chase trends and miss reversals. If logitReversionWeight is too high, the model will fade every move and miss breakouts.Start with the 2:1 ratio (150:80) and adjust based on backtest results.
engine.prediction.nearExpiryGuardSec
number
default:"5"
Seconds before expiry when momentum/reversion adjustments are disabled.When timeRemaining <= nearExpiryGuardSec, the model uses only the Black-Scholes base probability without logit adjustments.Range: 3 - 10
Rationale: Very close to expiry, momentum becomes noise and Black-Scholes distance-to-strike dominates.

Feeds Configuration

Data source configuration for price feeds and market APIs. Chainlink WebSocket feed parameters.
Maximum allowed price change between ticks as a fraction.If |newPrice - lastPrice| / lastPrice > spikeThreshold, the tick is rejected as a spike.Range: 0.05 - 0.20
Example: 0.10 allows 10% jumps, rejecting anything larger.
Implemented in src/feeds/chainlink.js to guard against WebSocket data corruption.

Polymarket

Polymarket API configuration for market discovery and price fetching.
feeds.polymarket.gammaBaseUrl
string
default:"https://gamma-api.polymarket.com"
Base URL for Polymarket Gamma API (event and market discovery).
feeds.polymarket.clobBaseUrl
string
default:"https://clob.polymarket.com"
Base URL for Polymarket CLOB API (market prices).
feeds.polymarket.slugPrefix
string
default:"btc-updown-5m-"
Slug prefix for filtering 5-minute BTC binary markets.Used in event discovery to identify relevant markets. Example market slug: btc-updown-5m-2026-03-04-1430
feeds.polymarket.pollIntervalSec
number
default:"5"
Seconds between Polymarket API polls for market prices.Range: 3 - 10
Recommended: 5
Higher values reduce API load but may miss price updates. Lower values increase API request volume.
feeds.polymarket.offsetsFallback
array
default:"[-300, 300]"
Fallback time offsets (in seconds) for market discovery when API fails.Type: number[]
Example: [-300, 300] searches from 5 minutes before to 5 minutes after the target timestamp.
feeds.polymarket.enabled
boolean
default:"true"
Master switch for Polymarket feed.Set to false to disable market price fetching (model predictions will still run, but EV/bet sizing will show N/A).

Storage Configuration

Data persistence paths.
storage.historyPath
string
default:"data/history.json"
Path to the JSON file storing interval history.Managed by src/tracker/history.js. Contains all resolved intervals with predictions, outcomes, and metadata.Format: JSON array of interval objects
Auto-created: Yes (parent directory created automatically)
Backup strategy: The history file grows continuously. Consider backing it up daily and rotating old data to archive storage.

Bot Configuration

Main event loop timing.
bot.loopIntervalMs
number
default:"1000"
Main loop sleep interval in milliseconds.The bot runs a tick-update-predict-display cycle, then sleeps for this duration.Range: 500 - 2000
Recommended: 1000 (1 second)
Lower values increase responsiveness but consume more CPU. Higher values reduce overhead but may miss rapid price changes.

Risk Configuration

Position sizing and risk management parameters.

Base Risk Parameters

risk.bankroll
number
default:"100"
Starting bankroll in USD.Used for position sizing and drawdown calculations. Update this to match your actual trading capital.
risk.maxBetPct
number
default:"0.05"
Maximum bet as a fraction of bankroll.Range: 0.02 - 0.10
Example: 0.05 caps bets at 5% of bankroll regardless of Kelly calculation.
Prevents overexposure from aggressive Kelly fractions.
risk.minBetUsd
number
default:"1"
Minimum bet size in USD.Bets smaller than this threshold are skipped (treated as abstention).Rationale: Avoids dust trades that don’t justify gas costs or trading fees.
risk.kellyFraction
number
default:"0.25"
Base Kelly fraction (deprecated in favor of Brier-based alpha tiers).Note: This parameter is not currently used. Position sizing uses the brierTiers system instead.

Drawdown Thresholds

4-level drawdown system with percentage thresholds from high-water mark.
risk.drawdown.yellowPct
number
default:"0.10"
Yellow level: 10% drawdown from high-water mark.Effect: Warning indicator (no impact on bet sizing).
risk.drawdown.redPct
number
default:"0.20"
Red level: 20% drawdown from high-water mark.Effect: Reduces Kelly alpha by 50%.
risk.drawdown.criticalPct
number
default:"0.30"
Critical level: 30% drawdown from high-water mark.Effect: Trading suspended (all bets blocked).
Drawdown protection is essential. Do not disable or increase criticalPct beyond 0.40 without careful consideration. A 40%+ drawdown requires 67% gains to recover.

Cold Streak Detection

risk.coldStreak.consecutiveMissThreshold
number
default:"5"
Number of consecutive misses before triggering cold streak warning.Note: Currently informational only. The abstention system uses the rolling window accuracy check instead (engine.abstention.minAccuracy).
risk.coldStreak.minConfidenceForStreak
number
default:"0.70"
Minimum confidence level for a prediction to count toward the cold streak counter.Rationale: Low-confidence misses (e.g., 55% predictions) are less concerning than high-confidence misses (e.g., 85% predictions).

Brier Tiers

Dynamic Kelly fraction based on model calibration quality (Brier Score).
risk.brierTiers
array
default:"[...]"
Array of Brier tier objects that map model performance to Kelly fraction alpha.Structure:
{
  "maxBrier": number | null,
  "minPredictions": number,
  "maxPredictions": number (tier 0 only),
  "alpha": number
}
Default tiers:
TierBrier ScoreMin PredictionsAlphaFractional Kelly
0Any0-990.00No trading
1> 0.26100+0.1010% Kelly
20.22-0.26100+0.2020% Kelly
30.18-0.22100+0.2525% Kelly
4< 0.18100+0.4040% Kelly
Implemented in src/risk/position-sizer.js:28-44.
Interpreting Brier Scores:
  • 0.25 = random coin flip
  • 0.20-0.22 = decent calibration (starting to beat the market)
  • 0.18-0.20 = good calibration (reliable edge)
  • < 0.18 = excellent calibration (strong edge)
The tier system automatically scales bet sizing as your model proves its accuracy over time.

Configuration Loader

The configuration is loaded synchronously at startup via src/config.js:6:
import { readFileSync } from 'fs'
import { fileURLToPath } from 'url'
import { dirname, join } from 'path'

const __dirname = dirname(fileURLToPath(import.meta.url))
const config = JSON.parse(
  readFileSync(join(__dirname, '..', 'config', 'default.json'), 'utf8')
)

export default config
Key characteristics:
  • No environment variable overrides (all config in JSON)
  • No runtime reloading (requires bot restart to apply changes)
  • Single source of truth: config/default.json

Next Steps

Tuning Parameters

Learn how to tune EWMA lambda, logit weights, and abstention thresholds for optimal performance.

Environment Setup

Set up data directories, configure logging, and prepare your environment for production.

Build docs developers (and LLMs) love