diff --git a/README.md b/README.md index 3cbd30ca..dd3056f8 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # 🌡️ PolyWeather: Intelligent Weather Quant Analysis Bot -PolyWeather is a weather analysis tool specifically designed for prediction markets like **Polymarket**. It aggregates multi-source forecasts, real-time airport METAR observations, and incorporates AI-driven decision support to help users evaluate weather-related risks more scientifically. +PolyWeather is a weather analysis tool built for prediction markets like **Polymarket**. It aggregates multi-source forecasts, real-time airport METAR observations, a math-based probability engine, and AI-driven decision support to help users evaluate weather trading risks more scientifically. --- @@ -8,28 +8,38 @@ PolyWeather is a weather analysis tool specifically designed for prediction mark ### 1. 🧬 Dynamic Ensemble Blending (DEB Algorithm) -The system automatically tracks the historical performance of various weather models (ECMWF, GFS, ICON, GEM, JMA) in specific cities: +The system automatically tracks the historical performance of weather models (ECMWF, GFS, ICON, GEM, JMA) per city: -- **Error-Based Weighting**: Dynamically adjusts weights for each model based on their Mean Absolute Error (MAE) over the past 7 days. -- **Blended Forecast**: Provides a "Blended High Temperature" recommendation corrected for historical biases. -- **Concurrency Optimization**: Built-in singleton cache and file locking mechanism to support high-concurrency queries and ensure data safety. +- **Error-Based Weighting**: Dynamically adjusts model weights based on their Mean Absolute Error (MAE) over the past 7 days. Lower error = higher weight. +- **Blended Forecast**: Provides a bias-corrected "DEB Blended High Temperature" recommendation. +- **Self-Learning**: Requires at least 2 days of observations before activating weight differentiation. Uses equal-weight averaging during cold start. +- **Concurrency Safe**: Built-in memory cache and file locking (fcntl) for high-concurrency group chat queries. -### 2. 🤖 AI Intelligent Analysis (Groq LLaMA 3.3) +### 2. 🎲 Math Probability Engine (Settlement Probability) -Integrates the LLaMA 70B model to interpret rapidly changing meteorological data: +Automatically computes the probability for each possible WU settlement integer using a Gaussian distribution fitted to the ensemble forecast: -- **Logical Deduction**: Considers dynamic factors such as wind speed, wind direction, cloud cover, and solar radiation to judge temperature trends. -- **Confidence Scoring**: Provides a confidence score from 1-10 for the current market conditions. -- **Automatic Cooldown Determination**: When temperature drop is observed or the forecast peak has passed, the AI provides a definitive market conclusion. +- **Method**: Derives standard deviation (σ) from the 51-member ensemble P10/P90, centers the distribution (μ) on a weighted average of DEB/multi-model median (70%) and ensemble median (30%). +- **Interval Integration**: Integrates over each WU rounding interval [N-0.5, N+0.5) to compute the probability of settling at integer N. +- **Display**: `🎲 Settlement Probability (μ=3.7): 4°C [3.5~4.5) 68% | 3°C [2.5~3.5) 32%` -### 3. ⏱️ Real-time Airport Observations (Zero-Cache METAR) +### 3. 🤖 AI Deep Analysis (Groq LLaMA 3.3 70B) -- **Live Passthrough**: Bypasses CDN caching via dynamic headers to obtain first-hand METAR reports from airports. -- **Settlement Warning**: Automatically calculates the Wunderground settlement boundary (X.5 rounding line) to warn of potential volatility. +Feeds wind speed, wind direction, cloud cover, solar radiation, and METAR trend data into LLaMA 70B: -### 4. 📈 Historical Data Collection +- **Logical Reasoning**: Uses 2-3 sentences to deeply analyze airport dynamics—whether conditions promote or inhibit warming, and whether the forecast can be reached. +- **Market Call**: Explicitly states the expected peak time window and the specific temperature betting range. Calls "dead market" when cooling is confirmed. +- **Confidence Score**: Quantitative 1-10 confidence rating. +- **High Availability**: Built-in auto-retry + fallback model degradation (70B → 8B) to withstand Groq API 500/503 outages. -- Includes `fetch_history.py` to retrieve up to 3 years of hourly historical weather data for any city, supporting future algorithm development. +### 4. ⏱️ Real-time Airport Observations (Zero-Cache METAR) + +- **Live Passthrough**: Bypasses CDN caching via dynamic headers to obtain first-hand METAR reports. +- **Settlement Warning**: Automatically calculates the Wunderground settlement boundary (X.5 rounding line). + +### 5. 📈 Historical Data Collection + +- Includes `fetch_history.py` to retrieve up to 3 years of hourly historical weather data (temperature, humidity, radiation, pressure, 10+ dimensions), providing data foundation for future ML models (XGBoost/MOS). --- @@ -65,15 +75,15 @@ chmod +x ~/update.sh ## 🕹️ Bot Commands -| Command | Description | -| :------------------ | :-------------------------------------------------------------------- | -| `/city [city_name]` | Get in-depth weather analysis, live tracking, and AI-driven insights. | -| `/id` | View the Chat ID of the current conversation. | -| `/help` | Display help information. | +| Command | Description | +| :------------------ | :------------------------------------------------------------------------------- | +| `/city [city_name]` | Get weather analysis, settlement probabilities, METAR tracking, and AI insights. | +| `/id` | View the Chat ID of the current conversation. | +| `/help` | Display help information. | -### Supported City Examples +### Supported Cities -`lon` (London), `par` (Paris), `ank` (Ankara), `nyc` (New York), `chi` (Chicago), `ba` (Buenos Aires), etc. +`lon` (London), `par` (Paris), `ank` (Ankara), `nyc` (New York), `chi` (Chicago), `dal` (Dallas), `mia` (Miami), `atl` (Atlanta), `sea` (Seattle), `tor` (Toronto), `sel` (Seoul), `ba` (Buenos Aires), `wel` (Wellington), etc. --- @@ -81,39 +91,43 @@ chmod +x ~/update.sh ```mermaid graph TD - User[User / Signal Receiver] -->|Query Command| Bot[bot_listener.py Core Scheduler] + User[User] -->|Query Command| Bot[bot_listener.py Core Scheduler] subgraph Data Acquisition Bot --> Collector[WeatherDataCollector] - Collector --> OM[Open-Meteo Live/Forecast] - Collector --> MM[Multi-Model Predictors ECMWF/GFS etc.] - Collector --> METAR[Live Airport Observations] + Collector --> OM[Open-Meteo Forecast/Ensemble] + Collector --> MM[Multi-Model ECMWF/GFS/ICON/GEM/JMA] + Collector --> METAR[Live Airport METAR] end - subgraph Logic Processing + subgraph Algorithm Layer Collector --> DEB[DEB Dynamic Weighting] - DEB --> DB[(daily_records JSON Database)] - Collector --> Logic[Settlement Analysis / Trend Detection] + DEB --> DB[(daily_records Database)] + Collector --> Prob[Gaussian Probability Engine] + Collector --> Logic[Settlement Boundary / Trend Analysis] end subgraph AI Decision Layer - DEB --> AIAnalyzer[Groq/LLaMA 3.3 AI Model] - Logic --> AIAnalyzer - METAR --> AIAnalyzer + DEB --> AI[Groq LLaMA 70B] + Prob --> AI + Logic --> AI + METAR --> AI end - AIAnalyzer -->|Generates: Spread+Logic+Confidence| Bot - Bot -->|Returns Analysis Snapshot| User + AI -->|Market Call + Logic + Confidence| Bot + Bot -->|DEB Blend + Probability + AI Analysis| User ``` --- ## 💡 Trading Tips -1. **Reference DEB Blended Value**: When models diverge, the DEB corrected value is usually more reliable than a single forecast. -2. **Observe AI Confidence**: A confidence score below 5 indicates high uncertainty in the current meteorological environment. -3. **Watch Settlement Boundaries**: When the observed high is near X.5, be wary of rounding jumps during Wunderground settlements. +1. **Watch Settlement Probability**: The probability engine is math-based and more objective than AI subjective judgment. When one temperature has > 65% probability, the direction is relatively clear. +2. **Reference DEB Blended Value**: When models diverge, the DEB corrected value is usually more reliable than any single forecast. +3. **Observe AI Confidence**: A score below 5 indicates high uncertainty—consider staying on the sidelines. +4. **Watch Settlement Boundaries**: When the observed high is near X.5, be wary of rounding jumps during WU settlements. +5. **Distribution Center μ**: The μ value shown in the probability display represents the algorithm's expected most likely actual high temperature—compare it directly with the Polymarket odds. --- -_Updated 2026_ +_Updated 2026-02-27_ diff --git a/README_ZH.md b/README_ZH.md index 8307dbef..2f57dc25 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,35 +1,45 @@ # 🌡️ PolyWeather: 智能天气量化分析机器人 -PolyWeather 是一款专为 **Polymarket** 等预测市场打造的天气分析工具。它通过聚合多源气象预报、实时机场 METAR 观测,并引入 AI 决策支持,帮助用户更科学地评估天气博弈风险。 +PolyWeather 是一款专为 **Polymarket** 等预测市场打造的天气分析工具。它通过聚合多源气象预报、实时机场 METAR 观测,并引入数学概率模型与 AI 决策支持,帮助用户更科学地评估天气博弈风险。 --- ## ✨ 核心功能 -### 1. � 动态权重集合预报 (DEB 算法) +### 1. 🧬 动态权重集合预报 (DEB 算法) 系统会自动追踪各个气象模型(ECMWF, GFS, ICON, GEM, JMA)在特定城市的历史表现: -- **误差加权**:根据过去 7 天的平均绝对误差(MAE),动态调整各模型的权重。 -- **融合预报**:给出经过历史偏差修正后的“融合最高温”建议值。 -- **并发优化**:内置单例缓存与文件锁,支持高并发查询,确保数据读写安全。 +- **误差加权**:根据过去 7 天的平均绝对误差(MAE),动态调整各模型的权重。误差越小的模型,话语权越大。 +- **融合预报**:给出经过历史偏差修正后的"DEB 融合最高温"建议值。 +- **自学习机制**:系统需要至少 2 天的实测记录才会启动权重分化。冷启动期间以等权平均过渡。 +- **并发优化**:内置内存缓存与文件锁 (fcntl),支持高并发群聊查询。 -### 2. 🤖 AI 智能分析 (Groq LLaMA 3.3) +### 2. 🎲 数学概率引擎 (Settlement Probability) -集成 LLaMA 70B 大模型,对瞬息万变的气象数据进行解读: +基于集合预报的正态分布拟合,自动计算每个 WU 结算整数温度的概率: -- **逻辑推演**:综合考虑风速、风向、云量、太阳辐射等动力因子,判断温度走势。 -- **置信度评分**:针对当前盘口给出 1-10 分的置信度参考。 -- **自动冷却判定**:当观测到气温明显回落或已过预报峰值时,AI 会给出明确的死盘结论。 +- **原理**:用 51 成员集合预报的 P10/P90 反推高斯分布标准差(σ),以 DEB/多模型中位数(70% 权重)和集合中位数(30%)的加权均值为分布中心(μ)。 +- **区间积分**:对每个 WU 取整区间 [N-0.5, N+0.5) 做正态积分,得到结算落入该整数的概率。 +- **展示格式**:`🎲 结算概率 (μ=3.7):4°C [3.5~4.5) 68% | 3°C [2.5~3.5) 32%` -### 3. ⏱️ 实时机场观测 (Zero-Cache METAR) +### 3. 🤖 AI 深度分析 (Groq LLaMA 3.3 70B) + +将风速、风向、云量、太阳辐射、METAR 趋势等全部投喂给 LLaMA 70B 大模型: + +- **逻辑推演**:用 2-3 句话深度分析机场动力因子对升温的促进/阻碍,判断最终能否达到预报值。 +- **盘口判定**:明确给出预计最热时段和具体博弈温度区间。降温确认后直接给出死盘结论。 +- **置信度评分**:1-10 分量化置信度参考。 +- **高可用保障**:内置自动重试 + 备用模型降级机制(70B → 8B),抵御 Groq API 503/500 故障。 + +### 4. ⏱️ 实时机场观测 (Zero-Cache METAR) - **实时穿透**:通过动态请求头绕过 CDN 缓存,获取机场第一手 METAR 报文。 - **结算预警**:自动计算 Wunderground 结算边界(X.5 进位线),提醒潜在波动。 -### 4. 📈 历史数据采集 +### 5. 📈 历史数据采集 -- 提供 `fetch_history.py` 脚本,可一键获取各城市过去 3 年的小时级历史气象数据,为后续算法开发提供支持。 +- 提供 `fetch_history.py` 脚本,可一键获取各城市过去 3 年的小时级历史气象数据(温度、湿度、辐射、气压等 10+ 维度),为后续机器学习模型(XGBoost/MOS)提供数据基础。 --- @@ -65,15 +75,15 @@ chmod +x ~/update.sh ## 🕹️ 机器人指令 -| 指令 | 说明 | -| :--------------- | :----------------------------------------- | -| `/city [城市名]` | 获取深度气象分析、实测追踪及 AI 决策建议。 | -| `/id` | 查看当前对话的 Chat ID。 | -| `/help` | 显示说明信息。 | +| 指令 | 说明 | +| :--------------- | :--------------------------------------------------- | +| `/city [城市名]` | 获取深度气象分析、结算概率、实测追踪及 AI 决策建议。 | +| `/id` | 查看当前对话的 Chat ID。 | +| `/help` | 显示说明信息。 | ### 支持城市示例 -`lon`(伦敦)、`par`(巴黎)、`ank`(安卡拉)、`nyc`(纽约)、`chi`(芝加哥)、`ba`(布宜诺斯艾利斯) 等。 +`lon`(伦敦)、`par`(巴黎)、`ank`(安卡拉)、`nyc`(纽约)、`chi`(芝加哥)、`dal`(达拉斯)、`mia`(迈阿密)、`atl`(亚特兰大)、`sea`(西雅图)、`tor`(多伦多)、`sel`(首尔)、`ba`(布宜诺斯艾利斯)、`wel`(惠灵顿) 等。 --- @@ -81,39 +91,43 @@ chmod +x ~/update.sh ```mermaid graph TD - User[用户 / 信号接收方] -->|查询指令| Bot[bot_listener.py 核心调度器] + User[用户] -->|查询指令| Bot[bot_listener.py 核心调度器] subgraph 数据获取层 Bot --> Collector[WeatherDataCollector] - Collector --> OM[Open-Meteo 实时/预报] - Collector --> MM[多模型预测集 ECMWF/GFS等] - Collector --> METAR[机场实时实测] + Collector --> OM[Open-Meteo 预报/集合] + Collector --> MM[多模型 ECMWF/GFS/ICON/GEM/JMA] + Collector --> METAR[机场实时 METAR] end - subgraph 逻辑处理层 - Collector --> DEB[DEB 动态权重算法] - DEB --> DB[(daily_records JSON 数据库)] - Collector --> Logic[结算分析 / 趋势判定] + subgraph 算法层 + Collector --> DEB[DEB 动态权重融合] + DEB --> DB[(daily_records 数据库)] + Collector --> Prob[正态分布概率引擎] + Collector --> Logic[结算边界 / 趋势分析] end subgraph AI 决策层 - DEB --> AIAnalyzer[Groq/LLaMA 3.3 AI 模型] - Logic --> AIAnalyzer - METAR --> AIAnalyzer + DEB --> AI[Groq LLaMA 70B] + Prob --> AI + Logic --> AI + METAR --> AI end - AIAnalyzer -->|生成: 盘口+逻辑+置信度| Bot - Bot -->|返回分析快照| User + AI -->|盘口 + 逻辑 + 置信度| Bot + Bot -->|DEB融合 + 概率 + AI分析| User ``` --- ## 💡 交易提示 -1. **参考 DEB 融合值**:当多模型分歧较大时,DEB 的修正值通常比单一预报更具参考意义。 -2. **观察 AI 置信度**:置信度低于 5 分时,说明当前气象环境处于高度不确定状态。 -3. **注意结算边界**:实测最高温接近 X.5 时,需警惕 Wunderground 结算时的进位跳动。 +1. **紧盯结算概率**:概率引擎基于数学模型计算,比 AI 的主观判断更客观。当某个温度概率 > 65%,说明方向较为明确。 +2. **参考 DEB 融合值**:当多模型分歧较大时,DEB 的修正值通常比单一预报更具参考意义。 +3. **观察 AI 置信度**:置信度低于 5 分时,说明当前气象环境处于高度不确定状态,建议观望。 +4. **注意结算边界**:实测最高温接近 X.5 时,需警惕 Wunderground 结算时的进位跳动。 +5. **分布中心 μ**:概率展示中的 μ 值代表算法预期的最可能实际最高温,可与 Polymarket 盘口价格直接对比。 --- -_更新于 2026_ +_更新于 2026-02-27_