docs: dividend_alert 路径更新 (2026-07-24 迁移)

【更新】longport-http-module.md line 82: 旧路径 ~/.hermes/scripts/dividend_alert.py → 新路径 ~/.hermes/skills/trading/dividend-investing/scripts/dividend_alert.py

其他 reference 文档 (devops/, software-development/) 不在 trading git 仓库, 本地已改但不同步
This commit is contained in:
2026-07-24 11:24:03 +08:00
parent cb752eeb88
commit 37f5ac8bd3
@@ -1,8 +1,8 @@
# longport_http.py 公共模块 (2026-07-21 新建)
# longport_http.py 公共模块 (2026-07-21 新建, 2026-07-23 更新 get_candlesticks)
## 背景
长桥 Python SDK (`openapi.QuoteContext` / `openapi.TradeContext`) 走 **WSS (WebSocket)**,而国内 VPS + Clash 代理下 WSS 经常超时 (`error sending request for url (https://openapi.longbridge.com/v1/socket/token): client error (Connect)`)。多次观察到:
长桥 Python SDK (`openapi.QuoteContext` / `openapi.TradeContext`) 走 **WSS (WebSocket)**,而国内 VPS + Clash 代理下 WSS 经常超时 (`error sending request for url (https://openapi.longport.com/v1/socket/token): client error (Connect)`)。多次观察到:
- 长桥 quote 公共 API (HTTP) 走 mihomo 代理**能通**
- 长桥 SDK WSS 走 mihomo 代理**必败**
@@ -12,7 +12,7 @@
## 公共模块: `~/.hermes/scripts/longport_http.py`
把长桥 CLI 封装成 Python SDK 风格的函数,所有脚本统一用这个模块(替代 `openapi.QuoteContext` / `openapi.TradeContext`)。
路径: `~/.hermes/scripts/longport_http.py`
### 提供函数
@@ -20,9 +20,23 @@
|------|------|------|
| `get_quote(symbol)` | `ctx.quote([symbol])` | 拿 1 只票实时报价, fallback candlesticks day |
| `get_quotes(symbols)` | `ctx.quote(batch)` | 批量,失败的 symbol 不会出现在结果里 |
| `get_candlesticks(symbol, period="day", count=30)` | `ctx.candlesticks(...)` | K 线,返回 `[{"timestamp","open","high","low","close","volume"},...]` |
| `get_positions()` | `trade_ctx.stock_positions()` | 查持仓 |
| `submit_order(...)` | `trade_ctx.submit_order(...)` | 下单 (limit) |
### get_candlesticks 详解 (2026-07-23 新增)
```python
klines = get_candlesticks('600519.SH', 'day', 5)
# 返回: [{"timestamp": "2026-07-23T00:00", "open": 1299.8, "high": 1299.97,
# "low": 1285.43, "close": 1294.95, "volume": 14448.0}, ...]
klines = get_candlesticks('NVDA.US', '5m', 30)
# period: 'day' | '5m' | '15m' | '1h' | '1m' 等
```
A 股价格单位是**元**,不需要除以 100。
### 内部实现
```python
@@ -51,7 +65,6 @@ if out:
if "" in price_str or len(price_str) < 4:
break # 截断, 走 candlesticks fallback
...
# fallback
cs_out = _run("candlesticks", symbol, "day", "--count", "1")
```
@@ -66,33 +79,17 @@ cs_out = _run("candlesticks", symbol, "day", "--count", "1")
## 已迁移的脚本
- `~/.hermes/scripts/dividend_alert.py`
- `~/.hermes/scripts/dca_monitor.py` (独立 module 写法, 待统一)
- 其他待迁移 (见 "推广" 章节)
- `~/.hermes/skills/trading/dividend-investing/scripts/dividend_alert.py` (2026-07-24 迁移到 skill 仓库)
- `~/.hermes/scripts/dca_monitor.py`
- `~/.hermes/skills/trading/strategy-management/scripts/calc_cn_levels.py` ✅ (2026-07-23 新建)
## 待迁移 (Phase 2)
| 脚本 | 当前 | 推广后 |
|------|------|--------|
| `~/.hermes/scripts/stock_t.py` | 直接调 ccxt | `from longport_http import get_quote, get_positions` |
| `~/.hermes/scripts/hk_intraday_monitor.py` (cron `e3667cb07aff`, paused) | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/us_intraday_monitor.py` (cron `bcdf70392251`, paused) | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/hk_intraday_close.py` | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/us_intraday_close.py` | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/daily_t_analysis.py` (cron `cb187ab5f9fc`, running) | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/daily_t_analysis.py` (cron `cb187ab5f9fc`) | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/dca_scanner.py` | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/rgti_alert.py` | 走 SDK | 改 longport_http |
| `~/.hermes/scripts/dividend_alert.py` | ✅ 已用 | - |
| `~/.hermes/scripts/dca_monitor.py` | ✅ 已用 | - |
**风险**: 14+ 个脚本都改,**全部需要回归测试**。
## 推广原则
1. **改一个测试一个** — 不要一次改多个
2. **5 次连续跑验证稳定** — 因为 mihomo 节点抽风可能
3. **保留原 SDK 代码注释** — 以防回退
4. **不删 SDK import** — 让模块兼容两种调用(但默认走 longport_http)
## 实战铁律 (2026-07-21)
@@ -103,7 +100,5 @@ cs_out = _run("candlesticks", symbol, "day", "--count", "1")
## 关联 reference
- `okx-auto-position/references/forced-skill-entry-okx-trade-2026-07-21.md` - 强制 skill 路径入口
- `longbridge-cli/SKILL.md` - 长桥 CLI 主文档
- `strategy-management/references/longbridge-cli-pitfalls-2026-07-16.md` - CLI 实战踩坑
- `~/.hermes/scripts/okx_trade.sh` - 类似的 OKX 标准入口 (对比参考)
- `strategy-management/SKILL.md` - A 股/港股/美股点位计算脚本(含 get_candlesticks 用法)