Weather prediction markets present a niche yet challenging arena for automated trading bots. WeatherBet tackles this by scanning Polymarket’s temperature outcome contracts across 20 global cities, seeking mispriced bets via a blend of ensemble weather forecasts and real-time data. What sets WeatherBet apart is its adaptive risk management: it learns forecast accuracy per city over time and adjusts its position sizing using a fractional Kelly Criterion. This approach balances edge exploitation with risk containment without relying on heavyweight external infrastructure.
what WeatherBet does and how it’s built
WeatherBet is an automated Python trading bot designed to operate on Polymarket’s weather prediction markets. Its primary goal is to identify contracts on temperature outcomes that are mispriced relative to actual forecast data. The bot cross-references market prices with temperature forecasts from three independent sources: ECMWF, HRRR/GFS models, and METAR airport weather stations. The latter is a notable choice—resolving markets using airport station data rather than city-center coordinates, which can differ by 3–8°F and significantly impact pricing in 1–2°F bucket markets.
The architecture centers on continuous scanning of Polymarket markets for opportunities. Once a market is identified, WeatherBet calculates the Expected Value (EV) of trading positions, filtering out those with negative EV to avoid unprofitable trades. It then determines position sizes using a fractional Kelly Criterion, which factors in the strength of the edge and incorporates risk controls like stop-loss and trailing stops set at 20% thresholds.
To improve over time, WeatherBet stores every forecast snapshot, trade executed, and market resolution locally in JSON files. This historical data allows the bot to learn the accuracy of forecasts on a per-city basis and adjust position sizing accordingly—a form of self-calibration that tightens risk management and potentially improves profitability.
The tech stack is straightforward: Python for the trading logic, with dependencies including the requests library for API calls. It integrates free APIs such as Open-Meteo, Aviation Weather, and Polymarket Gamma for data feeds, with an optional Visual Crossing API key to retrieve historical temperature data after market resolution.
technical strengths and design tradeoffs
WeatherBet’s standout feature is its use of a fractional Kelly Criterion for position sizing, calibrated dynamically based on forecast accuracy learned from stored trade and resolution history. Kelly Criterion is a mathematically grounded method to size bets in proportion to the edge and bankroll, but it is sensitive to estimation errors. By scaling the Kelly fraction conservatively (defaulting at 0.25) and using self-calibration, WeatherBet mitigates the risk of overbetting due to forecast uncertainty.
The choice to resolve markets against airport weather stations instead of city-center data is a pragmatic tradeoff. While airport data may not perfectly reflect city temperatures, it is more consistently reported and can materially affect the outcome buckets in Polymarket contracts. This attention to detail in data sourcing can offer an edge in pricing models.
From a data handling perspective, WeatherBet’s local JSON storage for forecasts, trades, and resolutions avoids the complexity of external databases or cloud infrastructure. This simplifies deployment and maintenance but may limit scalability and real-time data analysis capabilities.
The bot’s risk management includes stop-loss and trailing stops at 20% thresholds, which is a fairly standard approach to limit downside exposure and lock in profits as trades move favorably. The inclusion of slippage-aware order execution shows consideration for real-world trading conditions, where market impact and execution delays can erode theoretical profits.
One limitation is the reliance on free APIs, which can be rate-limited or less reliable than paid services. The optional Visual Crossing key helps fill gaps in historical data but is not mandatory. The bot’s performance hinges on the quality and timeliness of these data feeds.
The codebase is described as largely clean and focused, with configuration managed via a JSON file (config.json) that allows tuning parameters like balance, max bet size, minimum expected value, Kelly fraction, and scan interval. This makes it approachable for practitioners who want to adapt the bot to their own risk profiles or market conditions.
quick start
To get started with WeatherBet, the README provides a simple installation and configuration path:
git clone https://github.com/alteregoeth-ai/weatherbot
cd weatherbot
pip install requests
You then create a config.json file in the project folder with parameters like these:
{
"balance": 10000.0,
"max_bet": 20.0,
"min_ev": 0.05,
"max_price": 0.45,
"min_volume": 2000,
"min_hours": 2.0,
"max_hours": 72.0,
"kelly_fraction": 0.25,
"max_slippage": 0.03,
"scan_interval": 3600,
"calibration_min": 30,
"vc_key": "YOUR_VISUAL_CROSSING_KEY"
}
The Visual Crossing API key is optional but recommended to fetch actual temperatures after market resolution for calibration purposes. The bot then runs periodic scans (every hour by default) to find and execute trades within configured risk limits.
verdict
WeatherBet is a pragmatic Python trading bot that applies well-understood quantitative trading principles—expected value filtering, fractional Kelly sizing, and risk controls—to the niche domain of Polymarket weather prediction markets. Its self-calibrating approach to position sizing based on forecast accuracy is a solid technique to manage risk without overcomplicating the infrastructure.
This bot is best suited for developers or quantitative traders comfortable with Python and prediction markets who want a starting point for weather-based trading strategies. It’s not a plug-and-play high-frequency trading system but rather a well-architected experiment in automated market edge exploitation with transparent risk management.
Limitations include dependency on free API data quality and rate limits, potential scaling constraints due to local JSON storage, and the inherent unpredictability of weather markets. Still, the code is clean enough to be extended or adapted, and the calibration mechanism offers a foundation for iterative improvement.
If you’re interested in prediction markets and want to explore algorithmic trading beyond financial assets, WeatherBet offers a grounded, no-frills approach that’s worth understanding and building upon.
Related Articles
- Inside polymarket-kalshi-weather-bot: a multi-strategy prediction market trading bot with ensemble weather forecasting — Explore polymarket-kalshi-weather-bot, a Python trading bot exploiting BTC microstructure and ensemble weather forecasts
- A Python bot for safe mean-reversion trading on Polymarket with triple-gate live trading safety — An async Python bot automates a mean-reversion strategy on Polymarket’s non-sports binary markets. It features a triple-
- Lumibot: Unified Python trading library with AI agent runtime for reproducible strategy testing — Lumibot unifies backtesting and live trading for stocks, options, crypto, and forex with AI agent runtime using DuckDB,
- PokieTicker: layered AI-driven stock market analysis with sentiment and XGBoost — PokieTicker combines rule-based filtering, LLM sentiment analysis, and XGBoost prediction in a full-stack stock analysis
- ai-trader: AI-powered config-driven backtesting with natural language interaction — ai-trader adds natural language AI interaction to algorithmic trading backtesting via an MCP server and YAML configs. Su
→ GitHub Repo: alteregoeth-ai/weatherbot ⭐ 305 · Python