From eca0c7f514ffc3cb405805ce8022739a47e52086 Mon Sep 17 00:00:00 2001 From: "2569718930@qq.com" <2569718930@qq.com> Date: Thu, 12 Mar 2026 00:29:34 +0800 Subject: [PATCH] feat: Introduce multi-source weather data collection, including city configuration and robust caching. --- .env.example | 4 +- config/config.yaml | 21 +++++++- src/data_collection/city_registry.py | 66 +++++++++++++++++++++++++- src/data_collection/weather_sources.py | 14 ++++++ 4 files changed, 101 insertions(+), 4 deletions(-) diff --git a/.env.example b/.env.example index efa6b1b6..a95d6fa3 100644 --- a/.env.example +++ b/.env.example @@ -1,4 +1,4 @@ -# Telegram Bot +# Telegram Bot TELEGRAM_BOT_TOKEN=your_bot_token_here TELEGRAM_CHAT_ID=your_chat_id_here TELEGRAM_ALERT_PUSH_ENABLED=true @@ -8,7 +8,7 @@ TELEGRAM_ALERT_MIN_TRIGGER_COUNT=2 TELEGRAM_ALERT_MIN_SEVERITY=medium # Mispricing radar: skip push when YES buy price is above this cap (10c = 0.10) TELEGRAM_ALERT_MISPRICING_MAX_YES_BUY=0.10 -TELEGRAM_ALERT_CITIES=ankara,london,paris,seoul,toronto,buenos aires,wellington,new york,chicago,dallas,miami,atlanta,seattle,lucknow,sao paulo,munich +TELEGRAM_ALERT_CITIES=ankara,london,paris,seoul,hong kong,shanghai,singapore,tokyo,toronto,buenos aires,wellington,new york,chicago,dallas,miami,atlanta,seattle,lucknow,sao paulo,munich # AI GROQ_API_KEY=your_groq_api_key_here diff --git a/config/config.yaml b/config/config.yaml index 67bb35d4..27b73352 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -44,7 +44,26 @@ cities: country: "Germany" latitude: 48.3538 longitude: 11.7861 - + - id: "hong_kong" + city: "Hong Kong" + country: "China" + latitude: 22.3080 + longitude: 113.9185 + - id: "shanghai" + city: "Shanghai" + country: "China" + latitude: 31.1434 + longitude: 121.8052 + - id: "singapore" + city: "Singapore" + country: "Singapore" + latitude: 1.3644 + longitude: 103.9915 + - id: "tokyo" + city: "Tokyo" + country: "Japan" + latitude: 35.5523 + longitude: 139.7798 # Logging logging: level: "INFO" diff --git a/src/data_collection/city_registry.py b/src/data_collection/city_registry.py index ef145514..55ea9f9c 100644 --- a/src/data_collection/city_registry.py +++ b/src/data_collection/city_registry.py @@ -58,6 +58,62 @@ CITY_REGISTRY = { "distance_km": 48.8, "warning": "距离太远,海洋性vs大陆性气候差异大。", }, + "hong kong": { + "name": "Hong Kong", + "lat": 22.3080, + "lon": 113.9185, + "icao": "VHHH", + "tz_offset": 28800, + "use_fahrenheit": False, + "is_major": True, + "risk_level": "medium", + "risk_emoji": "🟡", + "airport_name": "Hong Kong 国际机场", + "distance_km": 31.0, + "warning": "海风与地形共同作用,午后对流触发后温度回落可能偏快。", + }, + "shanghai": { + "name": "Shanghai", + "lat": 31.1434, + "lon": 121.8052, + "icao": "ZSPD", + "tz_offset": 28800, + "use_fahrenheit": False, + "is_major": True, + "risk_level": "medium", + "risk_emoji": "🟡", + "airport_name": "浦东国际机场", + "distance_km": 33.0, + "warning": "沿海平流与城市热岛叠加,午后最高温落点易出现1-2°C偏差。", + }, + "singapore": { + "name": "Singapore", + "lat": 1.3644, + "lon": 103.9915, + "icao": "WSSS", + "tz_offset": 28800, + "use_fahrenheit": False, + "is_major": True, + "risk_level": "low", + "risk_emoji": "🟢", + "airport_name": "樟宜机场", + "distance_km": 17.5, + "warning": "全年温度振幅较小,主要受午后阵雨时段影响。", + }, + "tokyo": { + "name": "Tokyo", + "lat": 35.5523, + "lon": 139.7798, + "icao": "RJTT", + "tz_offset": 32400, + "use_fahrenheit": False, + "is_major": True, + "risk_level": "medium", + "risk_emoji": "🟡", + "airport_name": "羽田机场", + "distance_km": 15.0, + "warning": "湾风与热岛效应并存,日最高温时点有时会后移。", + }, "toronto": { "name": "Toronto", "lat": 43.6777, @@ -234,7 +290,10 @@ ALIASES = { "nyc": "new york", "ny": "new york", "chi": "chicago", "dal": "dallas", "mia": "miami", "atl": "atlanta", "sea": "seattle", "tor": "toronto", "sel": "seoul", - "seo": "seoul", "ba": "buenos aires", "wel": "wellington", + "seo": "seoul", "hkg": "hong kong", "hk": "hong kong", + "sha": "shanghai", "sh": "shanghai", "sin": "singapore", + "sg": "singapore", "tok": "tokyo", "tyo": "tokyo", + "ba": "buenos aires", "wel": "wellington", "luc": "lucknow", "sp": "sao paulo", "mun": "munich", # Chinese names @@ -249,6 +308,11 @@ ALIASES = { "西雅图": "seattle", "多伦多": "toronto", "首尔": "seoul", + "香港": "hong kong", + "上海": "shanghai", + "新加坡": "singapore", + "东京": "tokyo", + "東京": "tokyo", "布宜诺斯艾利斯": "buenos aires", "惠灵顿": "wellington", "勒克瑙": "lucknow", diff --git a/src/data_collection/weather_sources.py b/src/data_collection/weather_sources.py index 75999e04..624d5e7e 100644 --- a/src/data_collection/weather_sources.py +++ b/src/data_collection/weather_sources.py @@ -32,6 +32,10 @@ class WeatherDataCollector: "new york": ["KLGA", "KJFK", "KEWR", "KTEB", "KHPN"], "paris": ["LFPG", "LFPO", "LFPB"], "seoul": ["RKSI", "RKSS"], + "hong kong": ["VHHH", "VMMC", "ZGSZ"], + "shanghai": ["ZSPD", "ZSSS", "ZSNB", "ZSHC"], + "singapore": ["WSSS", "WSAP", "WMKK"], + "tokyo": ["RJTT", "RJAA", "RJAH", "RJTJ"], "toronto": ["CYYZ", "CYTZ", "CYKF"], "chicago": ["KORD", "KMDW", "KPWK", "KDPA"], "dallas": ["KDAL", "KDFW", "KADS", "KGKY"], @@ -1656,6 +1660,16 @@ class WeatherDataCollector: "亚特兰大": "Atlanta", "seoul": "Seoul", "首尔": "Seoul", + "hong kong": "Hong Kong", + "hong kong international airport": "Hong Kong", + "香港": "Hong Kong", + "shanghai": "Shanghai", + "上海": "Shanghai", + "singapore": "Singapore", + "新加坡": "Singapore", + "tokyo": "Tokyo", + "东京": "Tokyo", + "東京": "Tokyo", "toronto": "Toronto", "多伦多": "Toronto", "ankara": "Ankara",