2026-04-18 18:00:31 +08:00
# 🌦️ WeatherBet — Powered by Hermes Agent
2026-03-03 15:32:53 -06:00
2026-04-18 18:03:14 +08:00
> **Fully Autonomous Prediction Market Trading Bot** — Uses ECMWF weather forecast data to automatically find mispriced Polymarket markets and bet on them. Self-improves over time via the **Hermes Agent** framework.
2026-03-03 15:32:53 -06:00
2026-04-18 17:20:59 +08:00
[](https://www.python.org/downloads/)
[](https://polygon.technology/)
[](LICENSE)
2026-03-04 00:40:52 -06:00
---
2026-04-18 18:06:30 +08:00

2026-04-18 18:03:14 +08:00
## 🤖 Why Hermes Agent
2026-03-04 00:40:52 -06:00
2026-04-18 18:03:14 +08:00
This project demonstrates the power of **Hermes Agent** framework in autonomous trading:
2026-04-18 18:00:31 +08:00
2026-04-18 18:03:14 +08:00
| Hermes Agent Feature | Application in This Project |
2026-04-18 18:00:31 +08:00
|---|---|
2026-04-18 18:03:14 +08:00
| **Self-Learning & Evolution** | Bot automatically adjusts Kelly fraction and EV threshold from trade history |
| **Fully Autonomous Execution** | 60-min scan loop → signal calculation → auto order execution → on-chain settlement — zero human intervention |
| **Multi-Platform Gateway** | Real-time trade alerts via Telegram — control everything from your phone |
| **Persistent Memory** | Trade logs + learning models persist across sessions |
| **Model Agnostic** | Switch any LLM provider for decision reasoning |
| **Tool Orchestration** | Integrates weather API + on-chain CLOB trading + Telegram notifications |
2026-03-04 00:40:52 -06:00
2026-03-03 15:32:53 -06:00
---
2026-04-18 18:03:14 +08:00
## 🎯 What It Does
2026-03-03 15:32:53 -06:00
2026-04-18 18:03:14 +08:00
The bot monitors **6 US cities** (NYC, Chicago, Miami, Dallas, Seattle, Atlanta) and scans Polymarket temperature prediction markets for mispricing opportunities.
2026-03-03 15:32:53 -06:00
2026-04-18 18:03:14 +08:00
**Core Logic:** When weather forecast implies a different probability than what the market price suggests → calculate Expected Value (EV) → auto-bet if EV exceeds threshold.
2026-04-18 17:20:59 +08:00
---
2026-04-18 18:04:58 +08:00
## 🚀 Quick Start
### 1. Clone & Install
```bash
git clone https://github.com/nicolastinkl/hermes_weatherbot.git
cd hermes_weatherbot
python3.13 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
```
### 2. Configure
Copy the example env file and fill in your wallet credentials:
```bash
cp .env.example .env
```
Edit `.env` :
```env
# Your Polygon private key (hex, without 0x prefix)
PK = your_polygon_private_key_here
# Your Polygon wallet address
WALLET = 0xYourWalletAddressHere
# Signature type (0 = EOA)
SIG_TYPE = 0
```
Edit `config.json` to set your trading parameters:
```json
{
"max_bet" : 2.0 ,
"min_ev" : 0.10 ,
"min_volume" : 500 ,
"scan_interval" : 3600 ,
"telegram_bot_token" : "your_token" ,
"telegram_chat_id" : "your_chat_id"
}
```
### 3. Start Trading
```bash
# Start the bot (runs in background)
./start_bot_v3.sh
# Stop the bot
./stop_bot_v3.sh
```
That's it! The bot will continuously scan markets and trade automatically.
---
2026-04-18 18:03:14 +08:00
## 🧠 Core Math: Gaussian Bucket Model
2026-04-18 17:20:59 +08:00
2026-04-18 18:03:14 +08:00
### Step 1 — True Probability from ECMWF
2026-04-18 17:20:59 +08:00
```python
2026-04-18 17:23:28 +08:00
import math
def norm_cdf ( x ):
2026-04-18 18:03:14 +08:00
"""Cumulative distribution function of standard normal"""
2026-04-18 17:23:28 +08:00
return 0.5 * ( 1.0 + math . erf ( x / math . sqrt ( 2.0 )))
def bucket_prob ( forecast_temp , t_low , t_high , sigma = 2.0 ):
2026-04-18 17:20:59 +08:00
"""
2026-04-18 18:03:14 +08:00
Forecast says 72°F ± 2σ .
What's the probability actual high falls in 70-75°F bucket?
2026-04-18 17:23:28 +08:00
P(t_low ≤ X ≤ t_high) = CDF(z_high) - CDF(z_low)
2026-04-18 17:20:59 +08:00
"""
z_low = ( t_low - forecast_temp ) / sigma
z_high = ( t_high - forecast_temp ) / sigma
2026-04-18 17:23:28 +08:00
return norm_cdf ( z_high ) - norm_cdf ( z_low )
2026-04-18 17:20:59 +08:00
```
2026-04-18 18:03:14 +08:00
### Step 2 — Expected Value (EV)
2026-04-18 17:20:59 +08:00
```python
def calc_ev ( true_prob , market_price ):
"""
2026-04-18 18:03:14 +08:00
EV = P(win) × payoff - P(lose) × cost
EV > 0 → market is underpriced → BUY signal
2026-04-18 17:20:59 +08:00
"""
2026-04-18 18:00:31 +08:00
win = true_prob * ( 1 / market_price - 1 )
lose = ( 1 - true_prob ) * 1
2026-04-18 17:20:59 +08:00
return win - lose
```
2026-04-18 18:03:14 +08:00
**Example:**
- Forecast: 72°F → 75% chance of 70-75°F bucket
- Market price: $0.30 (implies 30% probability)
- `EV = 0.75 × (1/0.30 - 1) - 0.25 = +1.25` → **Strong BUY** 📈
2026-04-18 17:20:59 +08:00
2026-04-18 18:03:14 +08:00
### Step 3 — Kelly Criterion (Optimal Bet Sizing)
2026-04-18 17:20:59 +08:00
```python
def calc_kelly ( p , price ):
2026-04-18 18:03:14 +08:00
"""Kelly % = (bp - q) / b — uses 1/4 Kelly conservative fraction"""
2026-04-18 17:20:59 +08:00
b = 1.0 / price - 1.0
f = ( p * b - ( 1.0 - p )) / b
return round ( min ( max ( f , 0.0 ) * KELLY_FRAC , 1.0 ), 4 )
```
---
2026-04-18 18:03:14 +08:00
## 🌀 Auto-Evolution Learning System
2026-04-18 17:20:59 +08:00
2026-04-18 18:04:58 +08:00
This is a core strength of the Hermes Agent framework — the bot **learns from trading and auto-tunes** :
2026-04-18 17:20:59 +08:00
```
data/learning/
2026-04-18 18:03:14 +08:00
├── trade_log.json # All trades: city, bucket, cost, outcome, pnl
└── model.json # Learned parameters per city/bucket
2026-04-18 17:20:59 +08:00
```
2026-04-18 18:03:14 +08:00
**Adaptation Rules:**
- Winrate < 45% → Kelly fraction × 0.8, EV floor +10%
- Winrate > 55% + PnL > $2 → Kelly fraction × 1.1, EV floor − 5%
- Per-city winrate tracking adjusts confidence per market
- Starts conservative (25% Kelly) → converges to optimal as data accumulates
2026-04-18 17:20:59 +08:00
---
2026-04-18 18:03:14 +08:00
## 📊 Architecture
2026-04-18 17:20:59 +08:00
2026-04-18 18:00:31 +08:00
```
2026-04-18 18:03:14 +08:00
ECMWF Weather Forecast API
2026-04-18 18:00:31 +08:00
↓
2026-04-18 18:03:14 +08:00
Hermes Agent (Autonomous Decision Engine)
├── Gaussian Bucket Model → True Probability
├── calc_ev() → Expected Value Calculation
├── calc_kelly() → Optimal Bet Sizing
└── Adaptive Learning → Auto Parameter Tuning
2026-04-18 18:00:31 +08:00
↓
2026-04-18 18:03:14 +08:00
Polymarket CLOB (On-chain, Polygon)
2026-04-18 18:00:31 +08:00
↓
2026-04-18 18:03:14 +08:00
Telegram (Real-time Notifications)
2026-04-18 18:00:31 +08:00
```
2026-04-18 17:20:59 +08:00
2026-04-18 18:00:31 +08:00
---
2026-04-18 18:03:14 +08:00
## 🛡️ Risk Management
2026-03-03 15:32:53 -06:00
2026-04-18 18:03:14 +08:00
| Parameter | Value | Purpose |
2026-04-18 17:20:59 +08:00
|---|---|---|
2026-04-18 18:03:14 +08:00
| Max bet | $2.00 | Per-trade exposure cap |
| Kelly fraction | 25% | 1/4 Kelly conservative |
| Min EV | 10%+ | Only trade positive EV |
| Min volume | $500 | Avoid illiquid markets |
| Max spread | 3% | Avoid high-slippage |
| Adaptive floor | 10-20% | Self-tuning from performance |
2026-04-18 17:20:59 +08:00
---
2026-04-18 18:03:14 +08:00
## 🔐 Full Automated Trading Flow
2026-04-18 17:20:59 +08:00
2026-04-18 18:00:31 +08:00
```
2026-04-18 18:03:14 +08:00
1. Fetch ECMWF forecast (D+0 ~ D+3)
2. Query Polymarket temperature bucket markets
3. Gaussian model → true probability (σ =2°F)
4. Compare to market price → calculate EV
5. EV ≥ adaptive threshold → calculate Kelly bet size
6. Execute order on Polymarket CLOB (Polygon)
7. Record trade → update learning model
8. Telegram real-time notification
9. Repeat every 60 minutes
2026-04-18 18:00:31 +08:00
```
2026-04-18 17:20:59 +08:00
---
2026-04-18 18:03:14 +08:00
## 💡 Tech Stack
2026-04-18 17:20:59 +08:00
2026-04-18 18:03:14 +08:00
- **Framework:** Hermes Agent (autonomous learning + multi-platform)
- **Language:** Python 3.13
- **Trading:** [py_clob_client ](https://github.com/polymarket/py-clob-client ) — Polymarket CLOB
- **Weather:** ECMWF OpenMETAR / Open-Meteo API
- **Chain:** Polygon (Chain ID 137) — USDC.e stablecoin
- **Notifications:** Telegram Bot API
- **Learning:** Pure Python JSON persistence (zero DB dependency)
2026-04-18 17:20:59 +08:00
---
2026-04-18 18:03:14 +08:00
## ⚠️ Disclaimer
2026-04-18 18:00:31 +08:00
2026-04-18 18:03:14 +08:00
This bot trades real markets with real money. Past performance does not guarantee future results. Trade at your own risk. For educational and research purposes only.
2026-04-18 18:00:31 +08:00
---
*Built with 🐍 + Hermes Agent on Polygon — Autonomous Weather Prediction Trading.*