feat: Enhance data fusion with new sources (Meteoblue, MGM), add automated trend analysis, and update system architecture documentation.

This commit is contained in:
2569718930@qq.com
2026-02-08 19:49:58 +08:00
parent b0e9677815
commit 2450c63a3a
3 changed files with 109 additions and 129 deletions
+50 -66
View File
@@ -19,7 +19,7 @@ py -3.11 run.py
python3 run.py
```
_Note: The system is currently in **Weather Query Mode**. Active market monitoring and automated trading modules are suspended._
_Note: The system is currently in **Weather Query Mode**. Legacy active market monitoring and automated trading modules are suspended._
---
@@ -31,92 +31,76 @@ _Note: The system is currently in **Weather Query Mode**. Active market monitori
| `/id` | **Get Chat ID** | Retrieve your current Telegram Chat ID |
| `/help` | **Help** | Display all available commands |
### /city Command Example
```
/city Chicago
```
**Real-time Output:**
> 📍 **Chicago 天气详情**
> ⏱️ 生成时间: 12:45:30
> ════════════════════
> 🕐 当地时间: 12:45
>
> 📊 **Open-Meteo 7天预测**
> 👉 今天: 最高 22.4°F (NWS: 23°F)
> 02-08: 最高 26.2°F
> 02-09: 最高 37.2°F
>
> ✈️ **机场实测 (KORD)**
> 🌡️ 21.0°F (今日最高: 23.0°F)
> 💨 风速: 4kt
> 🕐 观测: 12:00 (当地)
>
> 💡 **态势分析**
> ⏱️ **预计峰值时刻**:今天 14:00 - 16:00 之间。
> 🎯 **博弈建议**:关注该时段实测能否站稳 22.4°F。
> 📈 **升温进程中**:距离峰值还有约 1.4° 空间,正向高点冲击。
---
## ✨ Key Features
### 1. 🏛️ Multi-Source Data Fusion
### 1. 🏛️ Multi-Source Data Fusion (High-Fidelity)
The bot aggregates data from multiple authoritative sources:
The bot aggregates data from multiple authoritative sources, layered by reliability:
| Source | Data Type | Coverage |
| -------------- | ------------------------------ | ----------------- |
| **Open-Meteo** | 7-day forecast | Global |
| **NWS** | Official US forecast | US cities only ⚠️ |
| **METAR** | Real-time airport observations | Global airports |
| Source | Role | Coverage | Strength |
| :----------------- | :---------------------- | :-------------- | :--------------------------------------------------------------------------------- |
| **Open-Meteo** | Base Forecast | Global | Provides detailed 72-hour temperature curves for all cities. |
| **Meteoblue (MB)** | **Precision Consensus** | Global | **Traders' choice**. Aggregates multiple models; excellent for microclimates. |
| **METAR** | **Settlement Standard** | Global Airports | The absolute truth for Polymarket settlement; real-time station data. |
| **NWS** | Official (US) | US Only | High-fidelity forecasts for US cities, critical for extreme weather events. |
| **MGM** | Official (Turkey) | Ankara | Direct access to Turkish State Meteorological Service for local official accuracy. |
- **⚠️ Divergence Alerts**: When Open-Meteo and NWS disagree by >1°F, the bot flags it for your attention.
### 2. ⚡ Ultra-Fresh Data (Cache-Busting)
### 2. ⏱️ Peak Timing Prediction
To counter second-by-second variations in weather betting, we implemented **Zero-Cache Technology**:
For each city, the bot analyzes the hourly forecast curve to identify:
- **Micro-timestamp Tokens**: Every request includes a dynamic token to force servers to bypass CDN caches.
- **MGM Real-time Sync**: Specialized header camouflaging to bypass local Turkish API anti-crawling for Ankara.
- **Exact peak window**: e.g., "14:00 - 16:00"
- **Betting recommendation**: Monitor real-time data during this window
### 3. ⏱️ Automated Trend Analysis
### 3. 📊 Today's High Tracking
The bot doesn't just fetch data; it interprets it:
METAR data is filtered by **local calendar day** using UTC offset:
- **Peak Window Prediction**: Automatically identifies the timeframe when today's record is most likely to be hit.
- **Risk Profiling**: Assigns risk levels based on geographic traits (e.g., Ankara high-altitude swings, London coastal microclimates).
- **Source Attribution**: Every data point is clearly labeled ([MGM], [METAR], [MB]) to help you weigh the data.
- Only observations from **local midnight onwards** are counted
- Ensures "Today's High" is accurate, not polluted by yesterday's warm afternoon
### 4. 📊 Smart Max-Temp Tracking
### 4. ✈️ High-Fidelity Airport Data (METAR)
Optimized for Polymarket settlement logic:
Directly connected to **NOAA Aviation Weather**, the bot fetches raw METAR data from major international airports.
- **Local Day Filtering**: Uses city UTC offsets to strictly count observations after 00:00 local time.
- **Multi-dimension Monitoring**: Includes "Feels Like" temperatures and 24h precipitation to assist in nuanced trade decisions.
- Automatic conversion from UTC to **City Local Time**.
- Real-time station observations (Temperature, Wind, Dew Point).
---
### 5. ⚡ Ultra-Fresh Data (Cache Busting)
## 🏗️ System Architecture
Engineered to bypass ISP and proxy caches:
PolyWeather uses a **Lightweight, Plugin-based** architecture for millisecond responses.
- Every request includes a **micro-timestamp token**.
- Forces weather servers (Open-Meteo/NOAA/NWS) to deliver fresh results instead of stale cached snapshots.
```mermaid
graph TD
User[/Telegram User/] --> Bot[bot_listener.py]
Bot --> Collector[WeatherDataCollector]
subgraph "Data Engine"
Collector --> OM[Open-Meteo API]
Collector --> MB[Meteoblue Scraper]
Collector --> NOAA[METAR Data Center]
Collector --> MGM[Turkish MGM API]
Collector --> NWS[US NWS API]
end
Collector --> Processing[Smart Analysis & Formatting]
Processing --> Bot
Bot --> Reponse[/Compact Betting Snapshot/]
```
- **Logic Decoupling**: `weather_sources.py` handles parsing; `bot_listener.py` handles rendering.
- **Legacy Modules**: `main.py` contains the old automated trading engine. Focus has shifted to "assisted manual decision-making."
---
## 🎯 Betting Strategy Tips
1. **Check model consensus**: If Open-Meteo and NWS agree, confidence is high.
2. **Watch the peak window**: Monitor METAR during predicted peak hours.
3. **Use "Today's High"**: Track the actual recorded maximum vs forecast.
4. **Interpret ⚠️ warnings**: Divergence means uncertainty—proceed with caution.
---
## 🏗️ Architecture Note
The project contains a legacy **Monitoring Engine** and **Paper Trading System** (located in `main.py`). These features are currently **deactivated** to prioritize high-speed on-demand weather reporting.
- To re-enable monitoring: Uncomment `monitor_thread.start()` in `run.py`.
- Documentation for inactive features: See [MARKET_DISCOVERY.md](./MARKET_DISCOVERY.md) and [PAPER_TRADING_GUIDE.md](./PAPER_TRADING_GUIDE.md).
1. **Check Consensus**: Compare Open-Meteo and Meteoblue (MB). Consensus usually implies higher probability.
2. **Watch the Peak**: Use `/city` frequently during predicted peak windows to catch momentum.
3. **Weighting Hierarchy**: Settlement is **METAR**; high-accuracy trend is **MB**; Official (NWS/MGM) is the "anchor."
4. **Geographic Risk**: Pay close attention to cities where "Bias will significantly amplify."
+50 -60
View File
@@ -34,89 +34,79 @@ _注意:系统当前处于 **天气查询模式**。主动市场监控和自
### /city 指令示例
```
/city 芝加哥
/city 伦敦
```
**实时输出:**
> 📍 **Chicago 天气详情**
> ⏱️ 生成时间: 12:45:30
> ════════════════════
> 🕐 当地时间: 12:45
>
> 📊 **Open-Meteo 7天预测**
> 👉 今天: 最高 22.4°F (NWS: 23°F)
> 02-08: 最高 26.2°F
> 02-09: 最高 37.2°F
>
> ✈️ **机场实测 (KORD)**
> 🌡️ 21.0°F (今日最高: 23.0°F)
> 💨 风速: 4kt
> 🕐 观测: 12:00 (当地)
>
> 💡 **态势分析**
> ⏱️ **预计峰值时刻**:今天 14:00 - 16:00 之间。
> **博弈建议**:关注该时段实测能否站稳 22.4°F。
> 📈 **升温进程中**:距离峰值还有约 1.4° 空间,正向高点冲击。
---
## ✨ 核心功能
### 1. 🏛️ 多源数据融合
### 1. 🏛️ 多源数据融合 (Multi-Source Fusion)
机器人聚合多个权威数据源
机器人聚合了全球最权威的几个数据源,并按权重进行分层
| 数据源 | 数据类型 | 覆盖范围 |
| -------------- | ------------ | ------------- |
| **Open-Meteo** | 7天预报 | 全球 |
| **NWS** | 美国官方预报 | 仅美国城市 ⚠️ |
| **METAR** | 机场实时观测 | 全球主要机场 |
| 数据源 | 数据角色 | 覆盖范围 | 优势 |
| :----------------- | :------------- | :--------- | :----------------------------------------------- |
| **Open-Meteo** | 基础预测 | 全球 | 提供所有城市的 72 小时精细化温度曲线 |
| **Meteoblue (MB)** | **高精度共识** | 全球 | **交易员首选**。聚合多家模型,对微气候处理极佳 |
| **METAR** | **结算标准** | 全球机场 | Polymarket 结算参考的绝对真理,实时机场观测 |
| **NWS** | 官方预测(美) | 仅限美国 | 美国国家气象局,对美国城市的极端天气预判准确 |
| **MGM** | 官方预测(土) | 仅限安卡拉 | 土耳其气象局,提供安卡拉 Esenboğa 机场的官方数据 |
- **⚠️ 分歧预警**:当 Open-Meteo 和 NWS 预测差异超过 1°F 时,机器人会标注提醒。
### 2. ⚡ 超新鲜数据 (Cache-Busting)
### 2. ⏱️ 峰值时刻预测
为了应对气象博弈中秒级的变化,我们实现了 **0 缓存技术**
机器人分析每个城市的逐小时预报曲线,识别:
- **微秒级令牌**:每个 API 请求都附带动态时间戳,强制气象服务器绕过 CDN 缓存返回最新值。
- **MGM 实时同步**:针对土耳其 MGM API 做了专门的 Header 伪装和时区校正。
- **精确峰值窗口**:如 "14:00 - 16:00"
- **博弈建议**:在此窗口期关注实测数据变化
### 3. ⏱️ 自动态势分析
### 3. 📊 今日最高温追踪
机器人不仅仅搬运数据,它还会进行逻辑加工:
METAR 数据按**当地日历日**过滤(使用 UTC 偏移):
- **峰值时刻预测**:自动计算今天气温最高点出现的概率窗口(如:14:00 - 15:00)。
- **风险等级 (Risk-Profile)**:根据地理特征(如安卡拉的高原温差、伦敦的近海微气候)自动分配风险等级。
- **数据溯源**:报表明确标注每个数字的来源([MGM], [METAR], [MB])。
- 只统计**当地零点之后**的观测记录
- 确保"今日最高"准确,不受昨天下午高温干扰
### 4. 📊 智能最高温追踪
### 4. ✈️ 高保真机场数据 (METAR)
针对 Polymarket 的结算逻辑进行优化:
直连 **NOAA 航空气象中心**,获取原始 METAR 数据:
- **当地日历日过滤**:基于城市 UTC 偏移,严格统计当地时间 00:00 之后的实测最高温。
- **多维度监测**:集成体感温度 (`feels_like`) 和 24h 累计降雨量,辅助多维度判断。
- 自动将 UTC 时间转换为**城市当地时间**
- 实时观测(温度、风速、露点)
---
### 5. ⚡ 超新鲜数据(缓存穿透)
## 🏗️ 系统架构
专门设计以绕过 ISP 和代理缓存:
本项目采用 **“轻量化、插件式”** 架构,旨在实现毫秒级响应。
- 每次请求附带**微秒时间戳令牌**
- 强制 Open-Meteo/NOAA/NWS 返回最新数据
```mermaid
graph TD
User[/Telegram User/] --> Bot[bot_listener.py]
Bot --> Collector[WeatherDataCollector]
subgraph "Data Engine"
Collector --> OM[Open-Meteo API]
Collector --> MB[Meteoblue Scraper]
Collector --> NOAA[METAR Data Center]
Collector --> MGM[Turkish MGM API]
Collector --> NWS[US NWS API]
end
Collector --> Processing[智能分析 & 格式化]
Processing --> Bot
Bot --> Reponse[/精简版博弈快照/]
```
- **逻辑解耦**`weather_sources.py` 负责外部数据的解析;`bot_listener.py` 负责消息模板渲染。
- **遗留模块说明**:项目根目录下的 `main.py` 包含旧版本的自动交易引擎。目前重心在“手动辅助决策”,如需开启请查阅 [MARKET_DISCOVERY_ZH.md](./MARKET_DISCOVERY_ZH.md)。
---
## 🎯 博弈策略提示
1. **检查模型共识**如果 Open-Meteo 和 NWS 一致,置信度高
2. **关注峰值窗口**:在预测的峰值时段多次刷新 METAR
3. **使用"今日最高"**:对比实测峰值与预报值
4. **解读 ⚠️ 警告**:分歧意味着不确定性——谨慎操作
---
## 🏗️ 架构说明
项目包含一个遗留的**监控引擎**和**模拟交易系统**(位于 `main.py`)。这些功能目前**已停用**,以优先保障高速按需天气查询。
- 重新启用监控:取消 `run.py``monitor_thread.start()` 的注释。
- 已停用功能的文档:参见 [MARKET_DISCOVERY_ZH.md](./MARKET_DISCOVERY_ZH.md) 和 [PAPER_TRADING_GUIDE.md](./PAPER_TRADING_GUIDE.md)。
1. **检查模型共识**查看 Open-Meteo 和 Meteoblue (MB) 是否达成共识
2. **关注峰值窗口**:在预测的峰值时段多次使用 `/city` 刷新。
3. **数据权重优先级**:结算以 **METAR** 为准,趋势预测以 **MB** 为准
4. **地理风险评估**:重点关注提示中的“偏差会显著放大”警告(如安卡拉、伦敦)
+9 -3
View File
@@ -274,16 +274,22 @@ def start_bot():
# 今天对比
today_t = max_temps[0] if max_temps else "N/A"
comp_parts = []
sources = ["Open-Meteo"]
if mb_high is not None:
sources.append("MB")
comp_parts.append(f"MB: {mb_high}")
if nws_high is not None:
sources.append("NWS")
comp_parts.append(f"NWS: {nws_high}")
if mgm_high is not None:
sources.append("MGM")
comp_parts.append(f"MGM: {mgm_high}")
if mb_high is not None:
comp_parts.append(f"MB: {mb_high}")
comp_str = f" ({' | '.join(comp_parts)})" if comp_parts else ""
sources_str = " | ".join(sources)
msg_lines.append(f"\n📊 <b>预报 (Open-Meteo)</b>")
msg_lines.append(f"\n📊 <b>预报 ({sources_str})</b>")
msg_lines.append(f"👉 <b>今天: {today_t}{temp_symbol}{comp_str}</b>")
# 明后天