feat: introduce model consensus scoring, ensemble forecast spread, and entry timing signals with enhanced trend analysis and updated documentation.

This commit is contained in:
AmandaloveYang
2026-02-21 10:43:13 +08:00
parent 6f0eaad6a8
commit 0333717bdb
3 changed files with 154 additions and 40 deletions
+74 -18
View File
@@ -1,6 +1,6 @@
# 🌡️ PolyWeather: Real-time Weather Query & Analysis Bot
An intelligent weather bot for prediction markets and professional weather betting. Fetches ultra-fresh data directly from global weather stations, bypassing CDN caches, and provides automated trend analysis in plain language.
An intelligent weather bot for prediction markets and professional weather betting. Fetches ultra-fresh data directly from global weather stations, bypassing CDN caches, and provides automated trend analysis with **model consensus scoring** and **entry timing signals** in plain language.
## 🚀 Quick Start
@@ -96,20 +96,62 @@ py -3.11 run.py
### 1. 🏛️ Multi-Source Data Fusion
| Source | Role | Coverage | Strength |
| :----------------- | :---------------------- | :-------------- | :--------------------------------------------------------------------------------- |
| **Open-Meteo** | Base Forecast | Global | 72-hour hourly temperature curves, sunrise/sunset times |
| **Meteoblue (MB)** | **Precision Consensus** | London Only | Multi-model aggregation; excellent for microclimates |
| **METAR** | **Settlement Standard** | Global Airports | Polymarket settlement source; real-time airport observations |
| **NWS** | Official (US) | US Only | US National Weather Service high-fidelity forecasts |
| **MGM** | Official (Turkey) | Ankara Only | Turkish State Met Service: pressure, cloud cover, feels-like, 24h rainfall |
| Source | Role | Coverage | Strength |
| :---------------------- | :---------------------- | :-------------- | :-------------------------------------------------------------------------- |
| **Open-Meteo** | Base Forecast | Global | 72h hourly curves, sunrise/sunset, **sunshine duration**, **shortwave radiation** |
| **Open-Meteo Ensemble** | **Uncertainty Range** | Global | 51-member ensemble: median, P10, P90 spread for confidence assessment |
| **Meteoblue (MB)** | **Precision Consensus** | London Only | Multi-model aggregation; excellent for microclimates |
| **METAR** | **Settlement Standard** | Global Airports | Polymarket settlement source; real-time airport observations |
| **NWS** | Official (US) | US Only | US National Weather Service high-fidelity forecasts |
| **MGM** | Official (Turkey) | Ankara Only | Turkish State Met Service: pressure, cloud cover, feels-like, 24h rainfall |
### 2. ⚡ Ultra-Fresh Data (Zero-Cache)
- **Dynamic Timestamps**: Every API request includes a unique token to force servers to bypass CDN caches.
- **MGM Real-time Sync**: Specialized header camouflaging and timezone correction for Turkish API.
### 3. 🧠 Smart Trend Analysis (Plain Language)
### 3. 🎯 Model Consensus Scoring (NEW)
The bot automatically rates how well different forecast sources agree, using a three-tier system:
| Level | Condition (°C / °F) | Meaning |
|:---|:---|:---|
| 🎯 **High** | Spread ≤ 0.8°C / 1.5°F | All models converge — high confidence, low risk |
| ⚖️ **Medium** | Spread ≤ 1.5°C / 3.0°F | Minor disagreement — moderate confidence |
| ⚠️ **Low** | Spread > 1.5°C / 3.0°F | Major divergence — high uncertainty, wait for more data |
Sources compared: Open-Meteo (OM), Meteoblue (MB), NWS, MGM — only **independent** forecast sources. Ensemble median is deliberately excluded to avoid double-counting with Open-Meteo.
### 4. 📊 Ensemble Forecast Spread (NEW)
Fetches 51-member ensemble forecasts from Open-Meteo to quantify prediction uncertainty:
> 📊 **Ensemble**: Median 10.8°C, 90% range [9.5°C - 12.1°C], spread 2.6°.
A tight range = high confidence in the forecast. A wide range = the atmosphere is chaotic, higher risk.
### 5. ⏰ Entry Timing Signal (NEW)
A composite score combining three factors to advise on betting timing:
| Factor | Score |
|:---|:---|
| Peak already passed | +3 |
| ≤ 2h to peak | +2 |
| ≤ 4h to peak | +1 |
| Model consensus: High | +2 |
| Model consensus: Medium | +1 |
| Actual ≈ Forecast (gap ≤ 0.5°) | +2 |
| Actual close to Forecast (gap ≤ 1.5°) | +1 |
| Total ≥ | Signal | Advice |
|:---|:---|:---|
| 5 | ⏰ **Ideal** | Low uncertainty — good to bet |
| 3 | ⏰ **Good** | Consider small positions |
| 2 | ⏰ **Cautious** | Keep observing |
| <2 | ⏰ **Not Recommended** | High uncertainty — wait |
### 6. 🧠 Smart Trend Analysis (Plain Language)
The bot generates human-readable insights automatically:
@@ -120,8 +162,11 @@ The bot generates human-readable insights automatically:
- **📉 Pressure Analysis**: Low pressure indicates warm/moist air passage.
- **🌧️ Rain Detection**: Cross-validates METAR weather codes with actual rainfall data to avoid false positives.
- **📊 Max Temperature Time Tracking**: Shows exactly when the daily high was recorded (e.g., `最高: 12°C @14:20`).
- **☀️ Weather Condition Summary**: Synthesizes METAR phenomena + cloud cover into a single glanceable icon + text (e.g., `⛅ Partly Cloudy`).
- **🌤️ Solar Radiation Analysis**: Tracks cumulative shortwave radiation vs. daily total; warns when clouds severely block sunlight.
- **🌙 Warm Advection Detection**: Identifies when peak temperature occurred during zero-radiation hours (e.g., 3 AM), proving the high was driven by warm air mass rather than solar heating.
### 4. 📊 Risk Profiling
### 7. 📊 Risk Profiling
Every city has a data bias risk profile based on airport-to-city-center distance:
@@ -129,6 +174,12 @@ Every city has a data bias risk profile based on airport-to-city-center distance
- 🟡 **Medium Risk**: Ankara (24.5km), Paris (25.2km), Dallas, Buenos Aires — systematic bias
- 🟢 **Low Risk**: London (12.7km), Wellington (5.1km) — reliable data
### 8. 🌅 Enhanced Display
- **Sunrise/Sunset + Sunshine Hours**: `🌅 07:34 | 🌇 18:29 | ☀️ 9.9h`
- **Weather Condition at a Glance**: `✈️ 实测 (METAR): 9°C | ⛅ Partly Cloudy | 15:00`
- **WU Settlement Preview**: Shows the Wunderground-rounded value for settlement reference.
---
## 🏗️ System Architecture
@@ -140,30 +191,35 @@ graph TD
subgraph "Data Engine"
Collector --> OM[Open-Meteo API]
Collector --> ENS[Open-Meteo Ensemble]
Collector --> MB[Meteoblue API]
Collector --> NOAA[METAR / NOAA]
Collector --> MGM[Turkish MGM API]
Collector --> NWS[US NWS API]
end
Collector --> Processing[Smart Analysis & Formatting]
Collector --> Processing[Consensus Scoring & Trend Analysis]
Processing --> Bot
Bot --> Response[/Compact Betting Snapshot/]
Bot --> Response[/Betting Snapshot with Entry Signal/]
```
- **Logic Decoupling**: `weather_sources.py` handles data fetching & parsing; `bot_listener.py` handles analysis & rendering.
- **City Config**: `city_risk_profiles.py` contains all METAR station mappings and risk assessments.
- **Ensemble Integration**: 51-member ensemble contributes to consensus scoring and provides P10/P90 uncertainty bands.
---
## 🎯 Betting Strategy Tips
1. **Check Consensus**: Compare Open-Meteo, Meteoblue (MB), and NWS/MGM forecasts.
2. **Watch the Peak Window**: Use `/city` frequently during predicted peak hours.
3. **Settlement Priority**: Settlement is always based on **METAR** data.
4. **Geographic Risk**: Pay attention to bias warnings, especially for high-risk cities.
5. **Wind Conflicts**: When METAR and MGM show opposite wind directions, expect temperature volatility.
1. **Check Model Consensus**: The 🎯/⚖️/⚠️ rating tells you immediately if the forecast is reliable.
2. **Use the Entry Signal**: Wait for ⏰ **Ideal** or **Good** timing before placing bets. Don't bet early when uncertainty is high.
3. **Watch Ensemble Spread**: A tight 90% band (< 2°) means model confidence is high — this is where edges live.
4. **Watch the Peak Window**: Use `/city` frequently during predicted peak hours.
5. **Settlement Priority**: Settlement is always based on **METAR** data, rounded to integer via Wunderground.
6. **Geographic Risk**: Pay attention to bias warnings, especially for high-risk cities like Seoul and Chicago.
7. **Solar Radiation Clues**: If the bot reports "warm advection driven" 🌙, the temperature was pushed by warm air, not sunlight — this pattern often breaks model predictions.
8. **Wind Conflicts**: When METAR and MGM show opposite wind directions, expect temperature volatility.
---
_Last updated: 2026-02-18_
_Last updated: 2026-02-21_
+79 -19
View File
@@ -1,6 +1,6 @@
# 🌡️ PolyWeather: 实时天气查询与分析机器人
专为预测市场和天气博弈设计的智能天气机器人。通过绕过 CDN 缓存直接从全球气象站获取最新数据,并提供通俗易懂的自动趋势分析。
专为预测市场和天气博弈设计的智能天气机器人。通过绕过 CDN 缓存直接从全球气象站获取最新数据,并提供**模型共识评分**和**入场时机信号**等通俗易懂的自动趋势分析。
## 🚀 快速开始
@@ -96,20 +96,66 @@ py -3.11 run.py
### 1. 🏛️ 多源数据融合
| 数据源 | 数据角色 | 覆盖范围 | 优势 |
| :----------------- | :------------- | :--------- | :--------------------------------------------------- |
| **Open-Meteo** | 基础预测 | 全球 | 72 小时逐小时温度曲线、日出日落时间 |
| **Meteoblue (MB)** | **高精度共识** | 仅限伦敦 | 聚合多家模型,对微气候处理极佳 |
| **METAR** | **结算标准** | 全球机场 | Polymarket 结算参考的绝对真理,实时机场观测 |
| **NWS** | 官方预测(美) | 仅限美国 | 美国国家气象局高精度预报 |
| **MGM** | 官方预测() | 仅限安卡拉 | 土耳其气象局:气压、云量、体感温度、24h 降水 |
| 数据源 | 数据角色 | 覆盖范围 | 优势 |
| :---------------------- | :------------- | :--------- | :----------------------------------------------------------- |
| **Open-Meteo** | 基础预测 | 全球 | 72h 逐小时温度曲线、日出日落、**日照时长**、**短波辐射** |
| **Open-Meteo Ensemble** | **不确定性区间** | 全球 | 51 成员集合预报:中位数、P10、P90 散度用于置信度评估 |
| **Meteoblue (MB)** | **高精度共识** | 仅限伦敦 | 聚合多家模型,对微气候处理极佳 |
| **METAR** | **结算标准** | 全球机场 | Polymarket 结算参考的绝对真理,实时机场观测 |
| **NWS** | 官方预测() | 仅限美国 | 美国国家气象局高精度预报 |
| **MGM** | 官方预测(土) | 仅限安卡拉 | 土耳其气象局:气压、云量、体感温度、24h 降水 |
### 2. ⚡ 超新鲜数据 (零缓存)
- **动态时间戳**:每个 API 请求都附带唯一令牌,强制服务器绕过 CDN 缓存。
- **MGM 实时同步**:针对土耳其 MGM API 做了专门的 Header 伪装和时区校正。
### 3. 🧠 智能趋势分析(通俗语言
### 3. 🎯 模型共识评分(新功能
机器人自动评估各预报源的一致程度,分为三个等级:
| 等级 | 条件(摄氏/华氏) | 含义 |
|:---|:---|:---|
| 🎯 **高共识** | 极差 ≤ 0.8°C / 1.5°F | 所有模型高度收敛 — 高置信,低风险 |
| ⚖️ **中共识** | 极差 ≤ 1.5°C / 3.0°F | 轻微分歧 — 中等置信 |
| ⚠️ **低共识** | 极差 > 1.5°C / 3.0°F | 模型严重分歧 — 不确定性大,建议观察 |
参与评分的数据源:Open-Meteo (OM)、Meteoblue (MB)、NWS、MGM — 仅限**独立**预报源。集合预报中位数不参与共识评分,避免与 Open-Meteo 确定性预报双重计数。
**核心逻辑**:当 3 个及以上模型在温度区间上高度收敛,而市场定价尚未反映时,这就是典型的**结构性定价错误**——低风险套利的黄金机会。
### 4. 📊 集合预报散度(新功能)
从 Open-Meteo 获取 51 成员集合预报,量化预测不确定性:
> 📊 **集合预报**:中位数 10.8°C90% 区间 [9.5°C - 12.1°C],波动幅度 2.6°。
区间窄 = 大气状态明确,预报可信。区间宽 = 大气混沌,风险高。
### 5. ⏰ 入场时机信号(新功能)
综合三个因子打分,给出入场建议:
| 因子 | 分值 |
|:---|:---|
| 最热已过 | +3 |
| 距峰值 ≤ 2h | +2 |
| 距峰值 ≤ 4h | +1 |
| 模型高共识 | +2 |
| 模型中共识 | +1 |
| 实测 ≈ 预报(差 ≤ 0.5°)| +2 |
| 实测接近预报(差 ≤ 1.5°)| +1 |
| 总分 ≥ | 信号 | 建议 |
|:---|:---|:---|
| 5 | ⏰ **理想** | 不确定性低,适合下注 |
| 3 | ⏰ **较好** | 可以考虑小仓位入场 |
| 2 | ⏰ **谨慎** | 建议继续观察 |
| <2 | ⏰ **不建议** | 不确定性大,等更多数据 |
**核心理念**:拒绝过早布局,选择接近解析时刻、波动率压缩时晚入场,降低不确定性风险。
### 6. 🧠 智能趋势分析(通俗语言)
机器人自动生成人类可读的分析洞察:
@@ -121,8 +167,11 @@ py -3.11 run.py
- **📉 气压分析**:低气压意味着暖湿气流过境,有利升温。
- **🌧️ 降雨检测**:交叉验证 METAR 天气代码和实际降水量,避免误报。
- **📊 最高温时间追踪**:精确显示每日最高温出现的时间(如 `最高: 12°C @14:20`)。
- **☀️ 天气状况一览**:综合 METAR 天气现象 + 云量,生成一目了然的天气图标 + 文字(如 `⛅ 晴间多云`)。
- **🌤️ 太阳辐射分析**:追踪累计短波辐射 vs 全天总量;当云层严重遮挡阳光时发出预警。
- **🌙 暖平流检测**:当最高温出现在太阳辐射为零的时段(如凌晨 3 点),自动识别并标注"气温由暖空气推高,而非太阳晒热"。
### 4. 📊 风险等级
### 7. 📊 风险等级
每个城市都有基于机场-市区距离的数据偏差风险档案:
@@ -130,6 +179,12 @@ py -3.11 run.py
- 🟡 **中危**:安卡拉 (24.5km)、巴黎 (25.2km)、达拉斯、布宜诺斯艾利斯 — 有系统偏差
- 🟢 **低危**:伦敦 (12.7km)、惠灵顿 (5.1km) — 数据靠谱
### 8. 🌅 增强显示
- **日出日落 + 日照时长**`🌅 07:34 | 🌇 18:29 | ☀️ 9.9h`
- **天气状况一目了然**`✈️ 实测 (METAR): 9°C | ⛅ 晴间多云 | 15:00`
- **WU 结算预览**:显示 Wunderground 四舍五入后的值,方便结算参考。
---
## 🏗️ 系统架构
@@ -139,32 +194,37 @@ graph TD
User[/Telegram User/] --> Bot[bot_listener.py]
Bot --> Collector[WeatherDataCollector]
subgraph "Data Engine"
subgraph "数据引擎"
Collector --> OM[Open-Meteo API]
Collector --> ENS[Open-Meteo Ensemble]
Collector --> MB[Meteoblue API]
Collector --> NOAA[METAR / NOAA]
Collector --> MGM[Turkish MGM API]
Collector --> NWS[US NWS API]
end
Collector --> Processing[智能分析 & 格式化]
Collector --> Processing[共识评分 & 趋势分析]
Processing --> Bot
Bot --> Response[/天气分析快照/]
Bot --> Response[/附带入场信号的天气快照/]
```
- **逻辑解耦**`weather_sources.py` 负责数据获取与解析;`bot_listener.py` 负责分析与渲染。
- **城市配置**`city_risk_profiles.py` 包含所有 METAR 机场映射和风险评估。
- **集合预报集成**:51 成员集合预报参与共识评分,并提供 P10/P90 不确定性区间。
---
## 🎯 博弈策略提示
1. **检查模型共识**对比 Open-Meteo、Meteoblue (MB) 和 NWS/MGM 的预报
2. **关注峰值窗口**:在预测的峰值时段频繁使用 `/city` 刷新
3. **结算优先级**:结算永远以 **METAR** 数据为准
4. **地理风险**:重点关注高危城市的偏差警告
5. **风向冲突**METAR 和 MGM 风向相反时,温度波动风险增大
1. **模型共识**🎯/⚖️/⚠️ 评级让你一眼判断预报是否可靠。高共识 + 市场低定价 = 套利机会
2. **用入场信号**:等 ⏰ **理想****较好** 时机再下注。不确定性高时绝不提前入场
3. **关注集合散度**:90% 区间越窄(< 2°),模型置信越高 — 这才是 edge 所在
4. **紧盯峰值窗口**:在预测的峰值时段频繁使用 `/city` 刷新
5. **结算优先级**结算永远以 **METAR** 数据为准,通过 Wunderground 四舍五入到整数
6. **地理风险**:重点关注高危城市(如首尔、芝加哥)的偏差警告。
7. **太阳辐射线索**:如果机器人报告"暖平流驱动" 🌙,说明温度由暖空气推高 — 这种模式经常打破模型预测。
8. **风向冲突**:METAR 和 MGM 风向相反时,温度波动风险增大。
---
_最后更新: 2026-02-18_
_最后更新: 2026-02-21_
+1 -3
View File
@@ -68,11 +68,9 @@ def analyze_weather_trend(weather_data, temp_symbol):
labeled_forecasts.append(("NWS", nws["today_high"]))
if mgm.get("today_high") is not None:
labeled_forecasts.append(("MGM", mgm["today_high"]))
# 集合预报中位数 (如果有)
# 集合预报数据 (仅用于不确定性区间展示,不参与共识评分,避免与 OM 双重计数)
ensemble = weather_data.get("ensemble", {})
ens_median = ensemble.get("median")
if ens_median is not None:
labeled_forecasts.append(("ENS", ens_median))
consensus_level = "unknown"
consensus_spread = None