A Polymarket weather bot is an automated trading script that monitors real-world weather data feeds, compares them against open Polymarket weather event contracts, identifies pricing discrepancies, and places trades programmatically when an edge exists.
Weather markets on Polymarket covering events like monthly temperature records, hurricane landfalls, and snowfall thresholds are among the most data-driven markets on the platform, making them highly suited to algorithmic approaches.
This guide covers the complete technical stack: API architecture, environment setup, weather data sourcing, strategy logic, and order execution in Python. This is an intermediate-to-advanced tutorial. You should be comfortable with Python, REST APIs, and basic crypto wallet management before proceeding.
- Polymarket weather bots use the CLOB API for order execution and the Gamma API for market discovery
- Weather data sources like NOAA and Open-Meteo are used to build probability models against market prices
- The core strategy is pricing arbitrage, finding markets where crowd probability diverges from data-implied probability
- All orders on Polymarket are limit orders expressed in USDC on the Polygon network
- Bot trading on Polymarket is permitted under its terms of service, provided no geo-restricted jurisdiction is involved
Understanding Polymarket’s API Architecture
Before writing a single line of code, you need to understand the three API layers your bot will interact with. Each serves a distinct purpose, and using the wrong one for the wrong task is the most common technical mistake beginners make. Full documentation is available at docs.polymarket.com.
- Gamma API (
https://gamma-api.polymarket.com): Market discovery and metadata, use this to find weather markets, their condition IDs, token IDs, and current prices. No authentication required. - CLOB API (
https://clob.polymarket.com): Order placement and cancellation, order book data, and real-time price streaming. Requires wallet authentication via API key derivation. - Data API (
https://data-api.polymarket.com): User-specific data including positions, trade history, and portfolio tracking. Used for post-trade monitoring. - WebSocket feed (
wss://ws-subscriptions-clob.polymarket.com/ws/): Real-time order book updates. Essential for any latency-sensitive strategy, REST polling introduces delays that can cause missed entries.
Setting Up Your Development Environment
Your bot runs on Python 3.10 or higher. The core dependencies are the official Polymarket Python CLOB client, a web3 wallet library, and a weather data client. Set up a clean virtual environment before installing anything.
Step 1: Install Dependencies
pip install py-clob-client
pip install web3
pip install python-dotenv
pip install requests
pip install pandas
Step 2: Configure Your Wallet and API Keys
Create a dedicated MetaMask wallet specifically for bot trading, never use your primary wallet. Fund it with USDC on Polygon and a small amount of MATIC for gas fees. Store your credentials in a .env file and never hardcode them in your scripts.
PRIVATE_KEY=your_wallet_private_key
POLYMARKET_HOST=https://clob.polymarket.com
CHAIN_ID=137
FUNDER_ADDRESS=your_wallet_address
Step 3: Initialize the CLOB Client
from clob_client.client import ClobClient
from eth_account import Account
import os
from dotenv import load_dotenv
load_dotenv()
private_key = os.getenv("PRIVATE_KEY")
wallet = Account.from_key(private_key)
client = ClobClient(
host=os.getenv("POLYMARKET_HOST"),
chain_id=int(os.getenv("CHAIN_ID")),
signer=wallet
)
# Derive API credentials from wallet
api_creds = client.derive_api_key()
print("API Key derived successfully:", api_creds.api_key)
Fetching Weather Markets from the Gamma API
Weather markets on Polymarket are tagged under specific event categories. Use the Gamma API to search for active weather markets and extract their condition IDs and token IDs, which are required for order placement.
import requests
def get_weather_markets():
url = "https://gamma-api.polymarket.com/markets"
params = {
"tag": "weather",
"active": "true",
"closed": "false",
"limit": 50
}
response = requests.get(url, params=params)
markets = response.json()
weather_markets = []
for market in markets:
weather_markets.append({
"question": market["question"],
"condition_id": market["conditionId"],
"token_yes": market["tokens"][0]["token_id"],
"token_no": market["tokens"][1]["token_id"],
"yes_price": float(market["tokens"][0]["price"]),
"no_price": float(market["tokens"][1]["price"]),
"volume": market.get("volume", 0)
})
return weather_markets
markets = get_weather_markets()
for m in markets:
print(f"{m['question']} | YES: {m['yes_price']} | NO: {m['no_price']}")
Connecting to a Weather Data Source
The edge in weather bot trading comes from comparing Polymarket’s crowd-implied probabilities against actual meteorological data. Two free, high-quality data sources work well for this purpose.
Option 1: Open-Meteo (Free, No API Key)
Open-Meteo provides free weather forecast data with no API key required, covering temperature, precipitation, wind speed, and more across global locations at hourly resolution up to 16 days ahead.
def get_temperature_forecast(latitude, longitude):
url = "https://api.open-meteo.com/v1/forecast"
params = {
"latitude": latitude,
"longitude": longitude,
"daily": "temperature_2m_max,temperature_2m_min,precipitation_sum",
"timezone": "auto",
"forecast_days": 14
}
response = requests.get(url, params=params)
return response.json()
# Example: New York City
forecast = get_temperature_forecast(40.7128, -74.0060)
print(forecast["daily"]["temperature_2m_max"])
Option 2: NOAA Climate Data Online
For historical verification and climate baseline data, the NOAA Climate Data Online API provides authoritative historical weather records. This is particularly useful for verifying how Polymarket resolves temperature and precipitation markets, as many resolution sources reference official NOAA station data.
NOAA_TOKEN = "your_noaa_token" # Free at https://www.ncdc.noaa.gov/cdo-web/token
def get_noaa_historical(station_id, start_date, end_date):
url = "https://www.ncdc.noaa.gov/cdo-web/api/v2/data"
headers = {"token": NOAA_TOKEN}
params = {
"datasetid": "GHCND",
"stationid": station_id,
"startdate": start_date,
"enddate": end_date,
"datatypeid": "TMAX,TMIN,PRCP",
"units": "metric",
"limit": 100
}
response = requests.get(url, headers=headers, params=params)
return response.json()
Building the Core Strategy Logic
The weather bot strategy is fundamentally a probability mispricing detector. Your weather model generates an estimated probability for a given outcome (e.g., “Will NYC reach 35°C in July?”). You compare this against Polymarket’s YES price, which represents the crowd’s implied probability. When your model’s probability diverges from the market price by more than your minimum edge threshold, the bot places a trade.
def calculate_edge(model_probability, market_yes_price, min_edge=0.05):
"""
model_probability: your weather model's estimated probability (0 to 1)
market_yes_price: Polymarket YES price in USDC (0 to 1)
min_edge: minimum required edge to place a trade
"""
edge = model_probability - market_yes_price
if edge > min_edge:
return {"action": "BUY_YES", "edge": round(edge, 4)}
elif edge < -min_edge:
return {"action": "BUY_NO", "edge": round(abs(edge), 4)}
else:
return {"action": "HOLD", "edge": round(abs(edge), 4)}
# Example
signal = calculate_edge(model_probability=0.72, market_yes_price=0.58)
print(signal) # {"action": "BUY_YES", "edge": 0.14}
Placing Orders via the CLOB API
All orders on Polymarket are limit orders. When your strategy generates a BUY signal, the bot submits a limit order at a price slightly above the current best ask to ensure fill. Review the full order creation reference at Polymarket’s order documentation before executing live trades.
from clob_client.order_builder.constants import BUY
def place_trade(client, token_id, price, size_usdc):
"""
token_id: YES or NO token ID from market data
price: limit price in USDC (e.g., 0.60 for 60 cents)
size_usdc: dollar amount to stake
"""
order_args = {
"token_id": token_id,
"price": price,
"size": size_usdc,
"side": BUY,
}
signed_order = client.create_order(order_args)
response = client.post_order(signed_order)
return response
# Only execute if edge meets threshold
signal = calculate_edge(0.72, 0.58)
if signal["action"] == "BUY_YES":
result = place_trade(
client=client,
token_id="your_yes_token_id",
price=0.60,
size_usdc=10
)
print(result)
Risk Controls You Must Build In
Running a live bot without risk controls is how accounts get blown out quickly. Before deploying any capital, implement the following safeguards as non-negotiable components of your bot architecture.
- Maximum position size per market: Cap each individual market position (e.g., no more than $50 per weather market)
- Maximum total exposure: Set a hard limit on total USDC deployed at any one time across all open positions
- Minimum liquidity filter: Only trade markets with sufficient order book depth, avoid markets with under $5,000 in volume where your orders move the price
- Model confidence threshold: Only trade when your weather model has sufficient historical accuracy for the market type, track your model’s Brier score before going live
- Dead man’s switch: Build a kill switch that halts all order placement if the bot’s daily loss exceeds a set threshold
- API rate limits: Polymarket’s REST API allows 60 requests per minute, use WebSocket streaming for price monitoring to stay well within limits
Also be aware of platform-level risk entirely outside your code. Understanding whether Polymarket can freeze your funds is as important as any technical safeguard you build into the bot itself.
Running and Monitoring Your Bot
For production deployment, run your bot on a cloud VPS rather than a local machine to ensure uptime. A low-latency server in New York or Frankfurt minimizes round-trip time to Polymarket’s infrastructure. Use a simple scheduler loop with a sleep interval matched to your strategy’s required update frequency.
import time
def run_bot(interval_seconds=60):
print("Weather bot started.")
while True:
try:
markets = get_weather_markets()
for market in markets:
forecast = get_temperature_forecast(40.7128, -74.0060)
model_prob = your_model_function(forecast, market)
signal = calculate_edge(model_prob, market["yes_price"])
if signal["action"] != "HOLD":
token = market["token_yes"] if signal["action"] == "BUY_YES" \
else market["token_no"]
place_trade(client, token, market["yes_price"] + 0.01, 10)
print(f"Trade placed: {signal['action']} on {market['question']}")
except Exception as e:
print(f"Bot error: {e}")
time.sleep(interval_seconds)
run_bot()
Frequently Asked Questions
Is running a trading bot on Polymarket allowed?
Yes. Polymarket’s terms of service permit automated trading bots. The platform’s CLOB API is publicly documented and explicitly designed for programmatic access. The only restrictions relate to geo-blocked jurisdictions bots operated from or on behalf of users in banned regions violate the terms of service.
What weather data source does Polymarket use to resolve weather markets?
Resolution sources vary by market and are specified in each market’s description on the platform. Common resolution sources include NOAA official station records, Weather Underground, and AccuWeather verified data. Always check the specific resolution source for each market before building your model your data source should match the resolution source as closely as possible.
How much capital do I need to start testing a weather bot?
You can test the bot’s market discovery and signal generation logic with zero capital using paper trading. For live execution testing, starting with $20 to $50 in USDC is sufficient to verify order flow without meaningful financial risk. Use our Polymarket payout calculator to model expected returns at different probability edges and stake sizes before committing real funds.
What is a good edge threshold for weather markets?
A minimum edge of 5% (0.05) is a common starting threshold, meaning your model’s implied probability must differ from the market price by at least 5 percentage points before the bot places a trade. Tighter thresholds generate more trades but increase the risk of acting on noise rather than genuine mispricing. Back-test your model on historical Polymarket weather markets before selecting a threshold. For broader strategic context, our Polymarket trading strategy guide covers edge identification principles that apply equally to manual and automated trading.

