diff --git a/.agent/skills/doc_refresher/SKILL.md b/.agent/skills/doc_refresher/SKILL.md new file mode 100644 index 00000000..3b4ad9b4 --- /dev/null +++ b/.agent/skills/doc_refresher/SKILL.md @@ -0,0 +1,27 @@ +--- +name: doc_refresher +description: 自动同步和刷新项目文档,确保 Markdown 文件与当前代码功能状态完全一致。 +--- + +# Documentation Refresher Skill + +此技能用于在项目架构发生重大调整(如功能下线、重心转移)后,自动重写和更新项目的所有 Markdown 文档。 + +## 核心任务 + +1. **代码扫描**:分析 `run.py` 和核心逻辑,识别哪些功能是“活跃的”,哪些功能是“暂停/移除的”。 +2. **术语统一**:确保所有文档使用一致的语气(例如从“监控机器人”转向“天气查询机器人”)。 +3. **多语言同步**:确保 `_ZH.md` 与英文版文档内容同步。 + +## 更新准则 + +- **状态准确性**:如果功能已在代码中被注释(如监控引擎、模拟交易),文档必须明确标注为“已暂停”或直接移除。 +- **示例更新**:更新文档中的 Telegram 指令示例,移除已下线的指令(如 `/signal`, `/portfolio`)。 +- **流程简化**:针对当前“天气查询模式”,简化安装和运行流程说明。 + +## 使用流程 + +1. 查看 `run.py` 确认当前运行模式。 +2. 遍历项目根目录下所有的 `.md` 文件。 +3. 对每个文件内容进行重构,保持格式美观。 +4. 校验多语言版本的一致性。 diff --git a/MARKET_DISCOVERY_ZH.md b/MARKET_DISCOVERY_ZH.md index a69b8869..5011bfdb 100644 --- a/MARKET_DISCOVERY_ZH.md +++ b/MARKET_DISCOVERY_ZH.md @@ -1,5 +1,8 @@ # Polymarket 天气市场搜寻技术文档 +> ⚠️ **当前状态:功能休眠** +> 本中提到的自动搜寻与监控引擎目前已在 `run.py` 中被注释。当前系统工作于“被动查询模式”,仅在用户输入 `/city` 指令时提供天气分析。 + 本文档详细说明了 PolyWeather 如何在 Polymarket 上自动识别、筛选并跟踪天气相关市场的技术实现逻辑。 ## 1. 数据来源 diff --git a/PAPER_TRADING_GUIDE.md b/PAPER_TRADING_GUIDE.md index 18b616ec..93efb9e2 100644 --- a/PAPER_TRADING_GUIDE.md +++ b/PAPER_TRADING_GUIDE.md @@ -1,5 +1,8 @@ # 📈 PolyWeather 模拟仓 (Paper Trading) 使用指南 +> ⚠️ **当前状态:功能暂停** +> 为了专注于高实时性的天气查询服务,自动模拟交易功能目前已在代码中被禁用。电报指令 `/portfolio` 暂不可用。 + 本系统提供全自动的模拟交易功能,让您在不投入真实资金的情况下,验证天气预测逻辑的盈利能力。 ## 🛠️ 运行机制 @@ -21,20 +24,20 @@ 系统结合 **Open-Meteo 天气预测**、**结算时间** 和 **成交量** 自动决定仓位大小: -| 条件组合 | 基础仓位 | 标签 | 说明 | -|----------|----------|------|------| -| 价格 ≥90¢ + 天气支持 + 高成交量 | **$10** | 🔥高置信 | 三重确认,重注 | -| 价格 ≥90¢ + 天气支持 | **$7** | ⭐中置信 | 双重确认 | -| 价格 ≥92¢ | **$5** | 📌价格锁定 | 纯价格锁定 | -| 其他 85-91¢ | **$3** | 💡试探 | 最小仓位试探 | +| 条件组合 | 基础仓位 | 标签 | 说明 | +| ------------------------------- | -------- | ---------- | -------------- | +| 价格 ≥90¢ + 天气支持 + 高成交量 | **$10** | 🔥高置信 | 三重确认,重注 | +| 价格 ≥90¢ + 天气支持 | **$7** | ⭐中置信 | 双重确认 | +| 价格 ≥92¢ | **$5** | 📌价格锁定 | 纯价格锁定 | +| 其他 85-91¢ | **$3** | 💡试探 | 最小仓位试探 | ### 风控过滤规则 -1. **时间衰减**: +1. **时间衰减**: - ≤1小时: 停止建仓 (0%) - 1-4小时: 缩小至 40% - 4-12小时: 缩小至 70% - - >12小时: 100% + - > 12小时: 100% 2. **预算上限**: 每日最高投入 $50 3. **成交量加权**: 低活跃市场额外缩减 20% @@ -46,6 +49,7 @@ ### 策略建议显示 当推送包含交易信号时,会附带策略建议: + ``` 💡 策略建议: • 预测温度19.0°C落在21°C区间,市场与模型一致 @@ -54,6 +58,7 @@ ### METAR 实测数据 当天结算的市场会额外显示机场实测数据,帮助验证预测准确性: + ``` ✈️ 机场实测 (KORD): 🌡️ 32.0°F | 风速:12kt diff --git a/README.md b/README.md index e4529e0b..fc6a97d0 100644 --- a/README.md +++ b/README.md @@ -1,298 +1,93 @@ -# 🌡️ PolyWeather: Polymarket Weather Trading Monitor +# 🌡️ PolyWeather: Real-time Weather Query & Analysis Bot -An intelligent monitoring and alerting system based on multi-source real-time meteorological data and Polymarket market pricing deviation analysis. +An intelligent weather information bot designed to provide ultra-fast, live meteorological data, high-fidelity forecasts, and smart trend analysis. Built for speed and accuracy, it bypasses network caching to deliver the most up-to-date reports from global weather stations. ## 🚀 Quick Start ### Requirements -- **Python 3.11** (Required for `py-clob-client` dependency) -- All dependencies installed: `pip install -r requirements.txt` +- **Python 3.11+** +- Dependencies: `pip install -r requirements.txt` -### Windows - -```powershell -# Option 1: Use Python 3.11 launcher -py -3.11 run.py - -# Option 2: Activate virtual environment first -.venv\Scripts\activate -python run.py -``` - -### Linux/VPS +### Running Locally (Windows/Linux) ```bash -# Use screen to keep it running in background -screen -S polyweather -python3.11 run.py +# Windows +py -3.11 run.py -# Detach: Press Ctrl+A then D -# Reattach: screen -r polyweather +# Linux/VPS +python3 run.py ``` -This command launches: - -1. **Monitoring Engine**: Scans markets 24/7, providing **85¢-95¢ Price Alerts** and **Market Anomalies**. -2. **Command Listener**: Handles Telegram commands and returns real-time signals. +_Note: The system is currently in **Weather Query Mode**. Active market monitoring and automated trading modules are suspended._ --- ## 🤖 Telegram Bot Commands -| Command | Description | Usage | -| :---------------- | :---------------------- | :--------------------------------------------- | -| `/signal` | **Get Trading Signals** | Returns Top 5 markets with earliest settlement | -| `/city [name]` | **Query City Details** | Get market info, forecast & live temperature | -| `/portfolio` | **View Portfolio** | Get real-time paper trading profit report | -| `/status` | **Check Status** | Confirm if the monitoring engine is online | -| `/help` | **Help** | Display all available commands | +| Command | Description | Usage | +| :------------- | :--------------------- | :--------------------------------------------- | +| `/city [name]` | **Query City Weather** | Get detailed forecasts, METAR & trend analysis | +| `/id` | **Get Chat ID** | Retrieve your current Telegram Chat ID | +| `/help` | **Help** | Display all available commands | ### /city Command Example ``` -/city chicago +/city London ``` -Output: -``` -📍 Chicago Market Details -════════════════════ +**Real-time Output:** -🕐 Local Time: 08:30 - -📊 Open-Meteo Forecast -👉 Today: High 38°F - 02-08: High 42°F - 02-09: High 45°F - -✈️ Airport Obs (KORD) - 🌡️ 32.0°F - 💨 Wind: 12kt - 🕐 Observed: 14:00 UTC - -📅 2026-02-07 Forecast:38°F -────────────────── -🔥 40-41°F: No 94¢ →Buy NO -🔥 38-39°F: Yes 91¢ →Buy YES -⭐ 36-37°F: No 87¢ →Buy NO -``` - -Supported abbreviations: `chi` (Chicago), `nyc` (New York), `atl` (Atlanta), `sea` (Seattle), `dal` (Dallas), `mia` (Miami) +> 📍 **London 天气详情** +> ⏱️ 生成时间: 00:41:17 +> ═══ ═══ ═══ ═══ ═══ ═══ +> 🕐 当地时间: 16:41 +> +> 📊 **Open-Meteo 7天预测** +> 👉 今天: 最高 12°C +> 02-09: 最高 11°C +> +> ✈️ **机场实测 (EGLC)** +> 🌡️ 10.0°C +> 💨 风速: 12kt +> 🕐 观测: 16:20 (当地) +> +> 💡 **态势分析** +> 📉 **处于降温期**:气温已开始从峰值下滑,今日大概率不会再反弹。 +> 🍃 **清劲风**:空气流动快,虽然有助于散热,但可能伴随阵风引起微小波动。 --- -## 🎯 Smart Dynamic Position Strategy +## ✨ Key Features -The system automatically decides the position size based on **Open-Meteo Weather Forecasts**, **Volume**, and **Price Locking Degree**: +### 1. 💡 Intelligent Trend Analysis -| Condition Combination | Size | Tag | Description | -| ------------------------------------------ | ------- | ----------------- | -------------------------------- | -| Price ≥90¢ + Weather Support + High Volume | **$10** | 🔥High Confidence | Triple confirmation, Heavy stake | -| Price ≥90¢ + Weather Support | **$7** | ⭐Mid Confidence | Double confirmation | -| Price ≥92¢ | **$5** | 📌Price Locked | Pure price locking | -| Other 85-91¢ | **$3** | 💡Probe | Minimum stake for probing | +The bot doesn't just show numbers; it performs a **Live vs. Forecast** analysis: -### Weather Support Logic +- **Peak Detection**: Determines if the daily high has likely already passed. +- **Atmospheric Physics**: Uses humidity and dew point to predict if the temperature will "stall" at night. +- **Volatility Alerts**: Flags high wind speeds that might cause rapid temperature swings. -- **Buy NO**: Open-Meteo predicted temperature is **outside** the option range (with ±2° tolerance). -- **Buy YES**: Open-Meteo predicted temperature **falls within** the option range. +### 2. ✈️ High-Fidelity Airport Data (METAR) -### Volume Detection +Directly connected to **NOAA Aviation Weather**, the bot fetches raw METAR data from major international airports. -- **High Volume**: Individual option volume ≥ $5,000. +- Automatic conversion from UTC to **City Local Time**. +- Real-time station observations (Temperature, Wind, Dew Point). + +### 3. ⚡ Ultra-Fresh Data (Cache Busting) + +Engineered to bypass ISP and proxy caches: + +- Every request includes a **micro-timestamp token**. +- Forces weather servers (Open-Meteo/NOAA) to deliver fresh results instead of stale cached snapshots. --- -## 📢 Alerting Dimensions +## 🏗️ Architecture Note -### 1. 📂 City Alert Summaries (Push) +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. -- **Optimization**: All anomalies for the same city are merged into a **single report** per scan cycle to prevent spamming. -- **Price Source**: Uses real **Ask price** (actual executable price), not mid price -- **Push Format**: - - ``` - 📍 Chicago Market Update - 🕐 Local 08:30 | Forecast High:38°F - ═══════════════════════ - - ✈️ Airport Obs (KORD): - 🌡️ 32.0°F | Wind:12kt - 🕐 Observed: 14:00 UTC - - ⚡ 40-41°F (2026-02-07): Buy No 87¢ | Prediction:38°F [🛒 $10.0 🔥High Conf] - - 💡 Strategy Tips: - • Predicted temp 38.0°F falls within 40-41°F range, market aligns with model - ``` - -### 2. ✈️ METAR Aviation Weather Data - -For same-day settlement markets, the system fetches **METAR airport observation data** and displays real measurements: - -``` -✈️ Airport Obs (KORD): - 🌡️ 12.0°F | Wind:15kt - 🕐 Observed: 11:00 UTC -``` - -**ICAO Airport Code Mapping**: - -| City | ICAO | Airport | -| ------------- | ---- | ---------------------------- | -| Seattle | KSEA | Seattle-Tacoma International | -| London | EGLC | London City Airport | -| Dallas | KDAL | Dallas Love Field | -| Miami | KMIA | Miami International | -| Atlanta | KATL | Hartsfield-Jackson Atlanta | -| Chicago | KORD | O'Hare International | -| New York | KLGA | LaGuardia Airport | -| Seoul | RKSI | Incheon International | -| Ankara | LTAC | Esenboga Airport | -| Toronto | CYYZ | Pearson International | -| Wellington | NZWN | Wellington International | -| Buenos Aires | SAEZ | Ministro Pistarini | - -**Data Source**: NOAA Aviation Weather Center (Free API, no key required) - -### 3. ⚡ Price Alerts (Auto Paper Trade) - -- **Trigger**: Buy Yes or Buy No price enters the **85¢-95¢** range. -- **Auto Action**: System executes a **$3-$10 Paper Trade** based on the dynamic position strategy. -- **Purpose**: High-probability / Near-settlement reminders. - -### 4. 👀 Market Anomalies - -- **Whale Inflow**: Large single trades (>$5,000) with imbalanced ratios. -- **Volume Spikes**: Sudden increase in volume (>2x historical std dev). - -### 5. 📅 Daily PnL Summary - -- **Trigger**: Triggered automatically around 23:55 (Beijing Time). -- **Content**: Summarizes daily floating PnL, balance changes, and win rate. - -### 6. 🎯 Trading Signals (`/signal`) - -Prioritizes markets with the **earliest settlement date**, sorted by opportunity value, returns **Top 5**: - -``` -🎯 Upcoming Settlement (2026-02-06) -43 active options - -🔥 1. Dallas 76-77°F - 💡 Prediction 80.7° above 77° → Buy NO ✓ - 📊 Buy No 94¢ | ⏳Near Lock - -🔥 2. Atlanta 56-57°F - 💡 Prediction 60.4° above 57° → Buy NO ✓ - 📊 Buy No 94¢ | ⏳Near Lock -``` - -**Lock Status**: - -- 🔒Locked: Price ≥95¢ -- ⏳Near Lock: Price 85-94¢ -- 👀Watch: Price 70-84¢ -- ⚖️Balanced: Price <70¢ - ---- - -## 📊 Paper Trading Report Format - -Accessible via `/portfolio`. Reports are grouped by **Target Settlement Date**: - -``` -📊 Paper Trading Report -════════════════════ - -📈 【2026-02-06】 Subtotal: +2.45$ -────────────────── -🟢 Chicago 40-41°F - NO 87¢→92¢ Pred:38 | +0.47$ -🟢 Chicago 32-33°F - NO 94¢→98¢ Pred:38 | +0.12$ - -💰 Total Exposure PnL: +6.89$ - -📈 Historical Stats: -Trades: 18 | Win Rate: 100.0% -Total Cost: $90.00 | Total PnL: +12.50$ (+13.9%) - -════════════════════ -💳 Account Balance: $639.11 -``` - ---- - -## 🛠️ Configuration (.env) - -```bash -# Telegram Bot -TELEGRAM_BOT_TOKEN=your_bot_token -TELEGRAM_CHAT_ID=your_chat_id - -# Polymarket API (Used for real-time prices & trade history) -POLYMARKET_API_KEY=your_api_key_here - -# Proxy (Optional, remove for VPS deployment) -HTTPS_PROXY=http://127.0.0.1:7890 -HTTP_PROXY=http://127.0.0.1:7890 -``` - -## 🏗️ Project Architecture - -This project is built on **py-clob-client** with REST API fallback: - -- Primary: Uses `py-clob-client` SDK for market data, orderbook, and trading -- Fallback: Direct REST API calls (`/price`, `/book`) when SDK fails -- Core API wrapper: `src/data_collection/polymarket_api.py` - -### Price Fetching - -```python -# SDK method (primary) -price = clob_client.get_price(token_id, side="BUY") - -# REST API fallback (when SDK fails) -resp = requests.get("https://clob.polymarket.com/price", params={ - "token_id": token_id, - "side": "BUY" -}) -``` - -## 📂 Data Files - -| File | Description | -| --------------------------- | ----------------------------------------------- | -| `data/paper_positions.json` | Paper trading positions, balance, trade history | -| `data/pushed_signals.json` | Pushed signals record (anti-spam) | -| `data/active_signals.json` | Currently active trading signals | -| `data/all_markets.json` | Full market cache | -| `data/price_history.json` | Price history for trend calculation | - ---- - -## 📋 Core Features - -- ✅ **Smart Dynamic Positions**: Automatic adjustment ($3-$10) based on weather forecasts, volume, and locking degree. -- ✅ **Predicted Temp Tracking**: Records the Open-Meteo forecast at the time of purchase for retrospective analysis. -- ✅ **Smart Merged Push**: City-based alert aggregation for a clean interface. -- ✅ **Auto Paper Trading**: Built-in system for tracking performance within the 85-95¢ range. -- ✅ **High-Speed Price Sync**: Utilizes CLOB batch API for instant price updates without 404s. -- ✅ **Timezone Adaptation**: All timestamps are automatically adjusted to Beijing Time (UTC+8). -- ✅ **Smart Date Selection**: Automatically targets the earliest active market date. -- ✅ **Unit Sensitivity**: US markets use Fahrenheit (°F), others use Celsius (°C). -- ✅ **Data Persistence**: Local JSON storage ensures consistency after restarts. - ---- - -## 🔄 VPS Update Instructions - -```bash -# 1. Local update -git add . && git commit -m "update" && git push - -# 2. VPS pull & restart -ssh root@VPS_IP "cd ~/PolyWeather && git pull && screen -S polyweather -X quit; screen -dmS polyweather python run.py" -``` +- 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). diff --git a/README_ZH.md b/README_ZH.md index ea5e2d6f..dcd12b11 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -1,303 +1,93 @@ -# 🌡️ PolyWeather: Polymarket 天气交易监控系统 +# 🌡️ PolyWeather: 实时天气查询与态势分析机器人 -基于多源实时气象数据与 Polymarket 市场定价偏差分析的智能监控与指令系统。 +基于多源实时气象数据(Open-Meteo、NOAA METAR)的智能天气分析系统。该系统专为速度与准确性设计,通过强制穿透网络缓存,为用户提供全球气象站最即时的实测报告与态势逻辑分析。 -## 🚀 运行指令 +## 🚀 快速开始 -### 环境要求 +### 环境依赖 -- **Python 3.11** (必须,`py-clob-client` 依赖要求) -- 已安装所有依赖:`pip install -r requirements.txt` +- **Python 3.11+** +- 安装依赖: `pip install -r requirements.txt` -### Windows 启动方式 - -```powershell -# 方式一:使用 Python 3.11 启动器 -py -3.11 run.py - -# 方式二:激活虚拟环境后运行 -.venv\Scripts\activate # 激活虚拟环境 -python run.py -``` - -### Linux/VPS 启动方式 +### 启动运行 (Windows/Linux) ```bash -# 使用 screen 保持后台运行 -screen -S polyweather -python3.11 run.py +# Windows +py -3.11 run.py -# 按 Ctrl+A 然后 D 退出但保持运行 -# 恢复:screen -r polyweather +# Linux/VPS +python3 run.py ``` -该命令会同时启动: - -1. **监控引擎**: 负责 7x24h 扫描并推送 **85¢-95¢ 价格预警** 与 **市场异常**。 -2. **指令监听器**: 监听电报指令并返回实时信号。 +_注:系统当前运行于**天气查询模式**。主动市场监控引擎和自动模拟交易模块已暂时关闭。_ --- -## 🤖 电报机器人指令集 +## 🤖 电报机器人指令 (Telegram) -| 指令 | 描述 | 用法 | -| :---------------- | :--------------- | :---------------------------- | -| `/signal` | **获取交易信号** | 返回最早结算市场的 Top 5 档位 | -| `/city [城市名]` | **查询城市详情** | 获取指定城市的市场、预测和实测温度 | -| `/portfolio` | **查看模拟仓位** | 获取实时模拟交易盈亏汇总报告 | -| `/status` | **检查系统状态** | 确认监控引擎是否在线 | -| `/help` | **指令帮助** | 显示所有可用指令 | +| 指令 | 描述 | 用法 | +| :--------------- | :--------------- | :--------------------------------------- | +| `/city [城市名]` | **查询城市天气** | 获取预测、机场实测及深度的“态势分析”结论 | +| `/id` | **获取 Chat ID** | 获取当前聊天的唯一 ID | +| `/help` | **帮助** | 显示所有可用指令 | ### /city 指令示例 ``` -/city chicago +/city 伦敦 ``` -返回内容: -``` -📍 Chicago 市场详情 -════════════════════ +**实时输出效果:** -🕐 当地时间: 08:30 - -📊 Open-Meteo 预测 -👉 今天: 最高 38°F - 02-08: 最高 42°F - 02-09: 最高 45°F - -✈️ 机场实测 (KORD) - 🌡️ 32.0°F - 💨 风速: 12kt - 🕐 观测: 14:00 UTC - -📅 2026-02-07 预测:38°F -────────────────── -🔥 40-41°F: No 94¢ →买NO -🔥 38-39°F: Yes 91¢ →买YES -⭐ 36-37°F: No 87¢ →买NO -``` - -支持城市缩写: `chi` (Chicago), `nyc` (New York), `atl` (Atlanta), `sea` (Seattle), `dal` (Dallas), `mia` (Miami) +> 📍 **London 天气详情** +> ⏱️ 生成时间: 00:41:17 +> ═══ ═══ ═══ ═══ ═══ ═══ +> 🕐 当地时间: 16:41 +> +> 📊 **Open-Meteo 7天预测** +> 👉 今天: 最高 12°C +> 02-09: 最高 11°C +> +> ✈️ **机场实测 (EGLC)** +> 🌡️ 10.0°C +> 💨 风速: 12kt +> 🕐 观测: 16:20 (当地) +> +> 💡 **态势分析** +> 📉 **处于降温期**:气温已开始从峰值下滑,今日大概率不会再反弹。 +> 🍃 **清劲风**:空气流动快,虽然有助于散热,但可能伴随阵风引起微小波动。 --- -## 🎯 智能动态仓位策略 +## ✨ 核心特性 -系统结合 **Open-Meteo 天气预测**、**成交量** 和 **价格锁定程度** 自动决定仓位大小: +### 1. 💡 智能态势分析 (Trend Analysis) -| 条件组合 | 仓位 | 标签 | 说明 | -| ------------------------------- | ------- | ---------- | -------------- | -| 价格 ≥90¢ + 天气支持 + 高成交量 | **$10** | 🔥高置信 | 三重确认,重注 | -| 价格 ≥90¢ + 天气支持 | **$7** | ⭐中置信 | 双重确认 | -| 价格 ≥92¢ | **$5** | 📌价格锁定 | 纯价格锁定 | -| 其他 85-91¢ | **$3** | 💡试探 | 最小仓位试探 | +机器人不再只是罗列数字,它通过**实测对比预测**的逻辑进行深度解读: -### 天气支持判断逻辑 +- **峰值判定**:分析当前时间点,判断日间最高温是否已经产生。 +- **物理态势**:利用湿度和露点数据,分析夜间气温是否存在“跌不动”的支撑点。 +- **波动预警**:根据机场风速监控,预警可能导致气温突变的锋面过境。 -- **买 NO**:Open-Meteo 预测温度在选项区间 **之外** (±2° 容差) -- **买 YES**:Open-Meteo 预测温度 **落入** 选项区间 +### 2. ✈️ 高保真机场实测 (METAR) -### 成交量判断 +直接对接 **NOAA (美国国家海洋和大气管理局)** 的官方接口: -- **高成交量**:单个选项成交量 ≥ $5,000 +- **自动时区转换**:将机场 UTC 观测时间自动转换为**城市当地时间**。 +- **专业级参数**:获取温度、风速、露点、相对湿度等专业观测值。 + +### 3. ⚡ 数据绝对实时 (Cache Busting) + +针对网络代理和 CDN 缓存进行了底层加固: + +- 每一个 API 请求均带有**微秒级随机时间戳**。 +- 强制穿透所有中间缓存,确保获取的是气象站此时此刻的最新读数。 --- -## 📢 推送维度说明 +## 🏗️ 架构说明 -### 1. 📂 城市预警汇总 (主动推送) +本项目包含一套遗留的 **监控引擎 (Monitoring Engine)** 和 **模拟交易系统 (Paper Trading)**(位于 `main.py`)。为了提供最高效的点对点天气查询服务,目前这些功能已处于**休眠状态**。 -- **优化机制**: 同一轮扫描中,同一城市的所有异动将**合并为一条消息**发送,拒绝刷屏。 -- **触发内容**: 包含该城市下所有符合条件的"价格预警"与"市场异常"。 -- **价格来源**: 推送使用真实 **Ask 价格**(实际可成交价格),而非中间价 -- **推送格式**: - - ``` - 📍 Chicago 市场动态 - 🕐 当地 08:30 | 预测最高:38°F - ═══════════════════════ - - ✈️ 机场实测 (KORD): - 🌡️ 32.0°F | 风速:12kt - 🕐 观测: 14:00 UTC - - ⚡ 40-41°F (2026-02-07): Buy No 87¢ | 预测:38°F [🛒 $10.0 🔥高置信] - - 💡 策略建议: - • 预测温度38.0°F落在40-41°F区间,市场与模型一致 - ``` - -### 2. ✈️ METAR 航空气象实测数据 - -当天结算的市场会自动获取 **METAR 机场实测数据**,在预警中显示真实观测值: - -``` -✈️ 机场实测 (KORD): - 🌡️ 12.0°F | 风速:15kt - 🕐 观测: 11:00 UTC -``` - -**ICAO 机场代码映射表**: - -| 城市 | ICAO | 机场名称 | -| ------------- | ---- | --------------------------- | -| Seattle | KSEA | Seattle-Tacoma International | -| London | EGLC | London City Airport | -| Dallas | KDAL | Dallas Love Field | -| Miami | KMIA | Miami International | -| Atlanta | KATL | Hartsfield-Jackson Atlanta | -| Chicago | KORD | O'Hare International | -| New York | KLGA | LaGuardia Airport | -| Seoul | RKSI | Incheon International | -| Ankara | LTAC | Esenboga Airport | -| Toronto | CYYZ | Pearson International | -| Wellington | NZWN | Wellington International | -| Buenos Aires | SAEZ | Ministro Pistarini | - -**数据源**: NOAA Aviation Weather Center (免费 API,无需 Key) - -### 3. ⚡ 价格预警 (触发模拟买入) - -- **触发条件**: Buy Yes 或 Buy No 价格在 **85¢-95¢** 区间。 -- **关联动作**: 系统根据智能仓位策略自动执行 **$3-$10** 的模拟开仓。 -- **用途**: 高胜率/即将锁定区间提醒,适合平仓或收割。 - -### 4. 👀 市场异常 - -- **大户入场**: 检测到单笔 >$5000 的大额交易且买卖比失衡。 -- **异常交易流**: 成交量突然放大 (>2倍历史标准差)。 - -### 5. 📅 每日盈亏总结 - -- **触发时间**: 北京时间 23:55 左右自动推送。 -- **内容**: 汇总当日所有模拟仓位的浮动盈亏、余额变动及胜率统计。 - -### 6. 🎯 交易信号 (`/signal` 指令) - -优先显示**最早结算日期**的市场,按机会价值排序,返回 **Top 5** 档位: - -``` -🎯 即将结算市场 (2026-02-06) -共 43 个活跃选项 - -🔥 1. Dallas 76-77°F - 💡 预测80.7°高于77° → 买NO ✓ - 📊 Buy No 94¢ | ⏳接近锁定 - -🔥 2. Atlanta 56-57°F - 💡 预测60.4°高于57° → 买NO ✓ - 📊 Buy No 94¢ | ⏳接近锁定 - -⭐ 3. Miami 62-63°F - 💡 预测65.3°高于63° → 买NO ✓ - 📊 Buy No 88¢ | ⏳接近锁定 -``` - -**锁定状态说明**: - -- 🔒锁定: 价格 ≥95¢ -- ⏳接近锁定: 价格 85-94¢ -- 👀观望: 价格 70-84¢ -- ⚖️均衡: 价格 <70¢ - ---- - -## 📊 模拟交易报告格式 - -通过 `/portfolio` 指令查看,报告按**目标日期分组**显示: - -``` -📊 模拟交易报告 -════════════════════ - -📈 【2026-02-06】 小计: +2.45$ -────────────────── -🟢 Chicago 40-41°F - NO 87¢→92¢ 预测:38 | +0.47$ -🟢 Chicago 32-33°F - NO 94¢→98¢ 预测:38 | +0.12$ - -💰 持仓总计: +6.89$ - -📈 历史战绩: -累计成交: 18笔 | 胜率: 100.0% -已投入: $90.00 | 盈亏: +12.50$ (+13.9%) - -════════════════════ -💳 账户余额: $639.11 -``` - ---- - -## 🛠️ 环境配置 (.env) - -```bash -# Telegram 机器人 -TELEGRAM_BOT_TOKEN=your_bot_token -TELEGRAM_CHAT_ID=your_chat_id - -# Polymarket API (用于批量获取实时盘口价格与交易历史) -POLYMARKET_API_KEY=your_api_key_here - -# 代理设置 (如需要,VPS 部署时可删除) -HTTPS_PROXY=http://127.0.0.1:7890 -HTTP_PROXY=http://127.0.0.1:7890 -``` - -## 🏗️ 项目架构 - -本项目基于 **py-clob-client** 官方客户端,并配备 REST API 备用方案: - -- 主要方式:使用 `py-clob-client` SDK 获取市场数据、订单簿、下单等 -- 备用方式:当 SDK 失败时,自动切换到直接 REST API 调用 (`/price`, `/book`) -- 核心 API 封装在 `src/data_collection/polymarket_api.py` - -### 价格获取 - -```python -# SDK 方式 (主要) -price = clob_client.get_price(token_id, side="BUY") - -# REST API 备用 (当 SDK 失败时) -resp = requests.get("https://clob.polymarket.com/price", params={ - "token_id": token_id, - "side": "BUY" -}) -``` - -## 📂 数据文件说明 - -| 文件 | 说明 | -| --------------------------- | -------------------------- | -| `data/paper_positions.json` | 模拟仓持仓、余额、交易历史 | -| `data/pushed_signals.json` | 已推送信号记录(防刷屏) | -| `data/active_signals.json` | 当前活跃交易信号 | -| `data/all_markets.json` | 全量市场缓存 | -| `data/price_history.json` | 价格历史(用于趋势计算) | - ---- - -## 📋 核心功能特性 - -- ✅ **智能动态仓位**: 结合天气预测、成交量、价格锁定程度自动调整仓位 ($3-$10)。 -- ✅ **预测温度追踪**: 每笔交易记录买入时的 Open-Meteo 预测温度,方便复盘验证。 -- ✅ **智能合并推送**: 按城市汇总预警,界面整洁不刷屏。 -- ✅ **全自动模拟交易**: 内置模拟仓位系统,支持 85-95¢ 区间自动跟单,记录实战胜率。 -- ✅ **极速价格同步**: 采用 Polymarket 批量 API 接口,一次同步全量城市,无延迟、无 404。 -- ✅ **北京时间适配**: 所有推送时间戳与每日总结均自动转换为北京时间 (UTC+8)。 -- ✅ **智能日期选择**: 自动定位最早的活跃市场日期,结算后自动顺延。 -- ✅ **温度单位自适应**: 美国市场切换华氏度 (°F),其他地区显示摄氏度 (°C)。 -- ✅ **全量数据持久化**: 信号记录、推送历史、交易仓位均保存至本地 JSON。 - ---- - -## 🔄 VPS 更新步骤 - -```bash -# 1. 本地推送代码 -git add . && git commit -m "update" && git push - -# 2. VPS 拉取并重启 -ssh root@VPS_IP "cd ~/PolyWeather && git pull && screen -S polyweather -X quit; screen -dmS polyweather python run.py" -``` +- 如需重新启用:请取消 `run.py` 中 `monitor_thread.start()` 的注释。 +- 遗留功能文档参见:[市场扫描说明](./MARKET_DISCOVERY_ZH.md) 和 [模拟交易指南](./PAPER_TRADING_GUIDE.md)。