diff --git a/README.md b/README.md index 0740d4b8..36ec0157 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ # 🌡️ PolyWeather: Intelligent Weather Quant Analysis Bot -[](https://github.com/yangyuan-zhen/PolyWeather/actions/workflows/python-app.yml) [](https://www.python.org/downloads/) [](https://opensource.org/licenses/MIT) [](https://deepwiki.com/yangyuan-zhen/PolyWeather) @@ -25,10 +24,11 @@ PolyWeather is a weather analysis tool built for prediction markets like **Polym ### 1. 🌐 Interactive Web Map Dashboard -- **Global Overview**: Real-time Leaflet-based map pinpointed exactly to the official Polymarket settlement airport coordinates. -- **Progressive Background Loading**: Intelligently fetches multi-source data across all cities seamlessly without hitting rate limits. -- **Rich Visualization**: Includes Chart.js-powered temperature trends, multi-model comparison bars, Gaussian probability distribution, and dynamic risk badges. -- **Dual-Engine Co-existence**: Runs concurrently with the Telegram bot using a FastAPI backend, sharing the exact same data and caching layers. +- **Global Overview**: Real-time Leaflet-based dark-themed map pinpointed to official Polymarket settlement airport coordinates. +- **Progressive Background Loading**: Intelligently fetches multi-source data across all cities without hitting API rate limits. +- **Rich Visualization**: Chart.js-powered temperature trends with METAR scatter overlay, multi-model comparison bars, Gaussian probability distribution, and dynamic risk badges. +- **Cinematic Interaction**: City selection triggers a smooth fly-to zoom animation on the map. +- **Dual-Engine Architecture**: Runs concurrently with the Telegram bot via a FastAPI backend, sharing the same data collection, analysis logic (`analyze_weather_trend`), and AI prompt pipeline. ### 2. 🧬 Dynamic Ensemble Blending (DEB Algorithm) @@ -40,17 +40,18 @@ The system automatically tracks the historical performance of weather models (EC - **Accuracy Tracking**: Use the `/deb` command to view DEB's historical WU settlement hit rate and MAE, compared against individual models. - **Auto-Cleanup**: Only retains the last 14 days of records to prevent unbounded data growth. -### 2. 🎲 Math Probability Engine (Settlement Probability) +### 3. 🎲 Math Probability Engine (Settlement Probability) -Automatically computes the probability for each possible WU settlement integer using a Gaussian distribution: +Automatically computes the probability for each possible settlement integer using a Gaussian distribution: -- **Distribution Center μ**: Weighted average of DEB/multi-model median (70%) and ensemble median (30%). Auto-corrects upward when METAR max exceeds μ. +- **Reality-Anchored μ**: When actual max temperature is significantly below forecasts during/after the peak window (forecast bust), μ anchors on the observed max instead of failed predictions. Otherwise, uses a weighted average of DEB/multi-model median (70%) and ensemble median (30%). - **Standard Deviation σ — Three-Layer Pipeline**: 1. **Ensemble Base**: σ = (P90-P10) / 2.56 - 2. **MAE Floor**: Uses DEB’s historical MAE as σ minimum—prevents ensembles from underestimating true uncertainty + 2. **MAE Floor**: Uses DEB's historical MAE as σ minimum—prevents ensembles from underestimating true uncertainty 3. **Shock Score Amplifier**: σ × (1 + 0.5 × shock_score) when weather is changing rapidly - **Time Decay**: Before peak σ×1.0 → During peak σ×0.7 → After peak σ×0.3 - **Observed Floor**: Temperatures below the current METAR max WU value are excluded +- **Dead Market Override**: When a dead market is confirmed, probability collapses to 100% at the settled value #### 💥 Shock Score: Weather Disruption Soft Scorer (0~1) @@ -62,25 +63,27 @@ Evaluates environmental stability from the last 4 METAR observations. Higher = m | Cloud Cover Jump | 0~0.35 | Cloud code escalation (FEW→BKN, etc.) | | Pressure Change | 0~0.25 | >2hPa change within 2 hours | -### 3. 🤖 AI Deep Analysis (Groq LLaMA 3.3 70B) +### 4. 🤖 AI Deep Analysis (Groq LLaMA 3.3 70B) -Feeds all weather data into LLaMA 70B, analyzed via a **P1→P4 Priority Chain**: +Feeds all weather data into LLaMA 70B, analyzed via a **P0→P4 Priority Chain**: -- **P1 Real-Time Rhythm** (highest priority): 2 consecutive METAR highs → still warming; 2 non-highs past peak → dead market. Warming under low radiation → advection-driven, forecasts often underestimate. -- **P2 Inhibitors**: Humidity >80% **and** BKN/OVC sustained 2 reports → effective suppression. "Partly cloudy" alone is insufficient. -- **P3 Math Probability**: References settlement probability but cannot override P1 observations. -- **P4 Forecast Background**: DEB/forecasts used for ceiling estimation; downweighted when actuals exceed them. -- **Dead Market Trigger**: Past peak window + 2 consecutive non-highs + cloud buildup or precipitation → dead market declared. -- **High Availability**: Auto-retry + fallback model degradation (70B → 8B) to withstand Groq API outages. +- **P0 Forecast Bust Detection** (highest priority): Graded severity (light/medium/heavy) when actual temps diverge from forecasts. Requires slope + wind/cloud verification before declaring settlement locked. "Bust ≠ locked" — still checks for second-wave warming. +- **P1 Real-Time Rhythm**: 2 consecutive METAR highs → still warming; 2 non-highs with slope ≤ 0 → dead market. Low-radiation warming → multi-factor (advection/mixing layer/heat island), no single-factor attribution. +- **P2 Inhibitors** (city-aware): Precipitation → strong suppression. High humidity + thick clouds sustained 2+ reports → possible suppression, but thresholds vary by city type (maritime vs. continental). Single factor insufficient. +- **P3 Probability Cross-Check**: References settlement probability for consistency check with P1. Contradictions explained with deviation rationale. +- **P4 Forecast Background**: DEB/forecasts for ceiling estimation; silenced when actuals significantly deviate. +- **Single Source of Truth**: Both web and Telegram bot share the same `analyze_weather_trend` function and `get_ai_analysis` prompt — identical context, identical decisions. +- **High Availability**: Auto-retry + fallback model degradation (70B → 8B). Proxy support for restricted networks. -### 4. ⏱️ Real-time Airport Observations (Zero-Cache METAR) +### 5. ⏱️ Real-time Airport Observations (Zero-Cache METAR) - **Precise Timing**: Extracts actual observation time from raw METAR text (`rawOb`), not the API's rounded `reportTime`. Accurate to the minute. - **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). -- **Anomaly Filtering**: Automatically filters out -9999 sentinel values from sources like MGM to prevent garbage data in output. +- **Settlement Warning**: Automatically calculates the settlement boundary (X.5 rounding line). +- **MGM Fallback**: For Turkish cities (Ankara), falls back to MGM data when METAR is unavailable. +- **Anomaly Filtering**: Automatically filters out -9999 sentinel values to prevent garbage data in output. -### 5. 📈 Historical Data Collection +### 6. 📈 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). @@ -148,48 +151,50 @@ _(Note: The `update.sh` script automatically fetches the latest code, kills old ```mermaid graph TD - User[User] -->|Query Command| Bot[bot_listener.py Core Scheduler] + User[User] -->|Query| Bot["bot_listener.py (Core Scheduler)"] + User -->|Browser| Web["web/app.py (FastAPI)"] subgraph Data Acquisition Bot --> Collector[WeatherDataCollector] + Web --> Collector Collector --> OM[Open-Meteo Forecast/Ensemble] Collector --> MM[Multi-Model ECMWF/GFS/ICON/GEM/JMA] - Collector --> METAR["Live Airport METAR (rawOb precise time)"] + Collector --> METAR["Live Airport METAR (rawOb)"] + Collector --> MGM["MGM Fallback (Turkey)"] end subgraph Algorithm Layer Collector --> Peak[Peak Hour Prediction] Collector --> DEB[DEB Dynamic Weighting] DEB --> DB[(daily_records Database)] - Peak --> Prob[Gaussian Probability Engine] + Peak --> Prob["Probability Engine (Reality-Anchored μ)"] Collector --> Prob METAR --> Shock[Shock Score] Shock --> Prob - Collector --> Logic[Settlement Boundary / Trend Analysis] + Collector --> Logic["Settlement Boundary / Dead Market"] end - subgraph AI Decision Layer - DEB --> AI[Groq LLaMA 70B] - Prob --> AI - Logic --> AI - METAR --> AI + subgraph Shared Analysis + Bot --> ATF["analyze_weather_trend()"] + Web --> ATF + ATF --> AI["Groq LLaMA 70B (P0→P4)"] end AI -->|Market Call + Logic + Confidence| Bot - Bot -->|DEB Blend + Probability + AI Analysis| User + AI -->|Market Call + Logic + Confidence| Web ``` --- ## 💡 Trading Tips -1. **Real-time Rhythm First**: AI analysis follows P1→P4 priority. If live METAR trends (P1) conflict with math probabilities (P3)—e.g., probability favors 7°C but it’s still surging toward 8°C—always prioritize the live trend. +1. **Real-time Rhythm First**: AI analysis follows P0→P4 priority. If live METAR trends (P1) conflict with math probabilities (P3), always prioritize the live trend. 2. **Watch Settlement Probabilities**: Based on Gaussian models, direction is most certain when a temperature has > 70% probability while P1 rhythm is flat. 3. **Reference DEB Bias**: Use `/deb` to check for systematic bias. If a city is consistently "underestimated," habitually bid one WU notch higher. -4. **Identify Dead Market Signals**: When AI declares a "Dead Market," it usually means warming power is exhausted (post-peak window + no new highs + cloud buildup). This is an opportunity to harvest remaining value. -5. **Mind the Boundaries**: When the observed high is near X.5 (e.g., 7.50°C), be wary of Wunderground rounding up to 8 due to tiny fluctuations. -6. **Center Point μ**: The μ value represents the expected actual high. When market prices deviate significantly from μ, an arbitrage opportunity may exist. +4. **Identify Dead Market Signals**: When the system declares a "Dead Market," probability collapses to 100% at the settled value. Warming power is exhausted. +5. **Mind the Boundaries**: When the observed high is near X.5 (e.g., 7.50°C), be wary of rounding up due to tiny fluctuations. +6. **Forecast Bust Awareness**: When the AI reports a forecast bust (especially medium/heavy grade), all model predictions have lost reference value. Focus exclusively on METAR actuals. --- -_Updated 2026-03-03_ +_Updated 2026-03-04_ diff --git a/README_ZH.md b/README_ZH.md index 2aba6b6e..bfdefc6c 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,6 +1,5 @@ # 🌡️ PolyWeather: 智能天气量化分析机器人 -[](https://github.com/yangyuan-zhen/PolyWeather/actions/workflows/python-app.yml) [](https://www.python.org/downloads/) [](https://opensource.org/licenses/MIT) [](https://deepwiki.com/yangyuan-zhen/PolyWeather) @@ -16,7 +15,7 @@ PolyWeather 是一款专为 **Polymarket** 等预测市场打造的天气分析
- 🗺️ 交互式网页地图:全球城市实时监控与丰富的数据可视化可视化
+ 🗺️ 交互式网页地图:全球城市实时监控与丰富的数据可视化