Skip to content

Commit 3471504

Browse files
committed
fix: harden Feishu websocket and stock context
1 parent 7ab281d commit 3471504

19 files changed

Lines changed: 214 additions & 130 deletions

File tree

feishu/ws.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
The SDK handles protobuf decoding automatically.
44
"""
55
import os
6+
import time
67
import threading
78
from datetime import datetime
89
from lark_oapi.ws import Client as LarkWSClient
@@ -63,15 +64,17 @@ def on_event(event_obj):
6364
app_secret=FEISHU_APP_SECRET,
6465
log_level=LogLevel.ERROR,
6566
event_handler=dispatcher,
66-
auto_reconnect=False, # we handle reconnection ourselves
67+
auto_reconnect=True,
6768
)
6869
_log("CONNECTED")
6970
print("[WS] 已连接", flush=True)
7071
client.start()
71-
except (OSError, RuntimeError) as e:
72+
_log("DISCONNECTED: client.start returned")
73+
print(f"[WS] 连接结束,{reconnect_delay}秒后重连...", flush=True)
74+
time.sleep(reconnect_delay)
75+
except Exception as e:
7276
_log(f"DISCONNECTED: {e}")
7377
print(f"[WS] 连接断开: {e}{reconnect_delay}秒后重连...", flush=True)
74-
import time
7578
time.sleep(reconnect_delay)
7679

7780

skills/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@ always_load: true # 可选,始终加载到上下文
6161

6262
- **新入场信号** → 往 `stock-analyzer/references/entry-signals.md` 加一个章节
6363
- **新市场分析方法** → 往 `market-analyzer/references/` 加一个 `.md`
64-
- **新筛选策略** → 往 `stock-screener/references/` 加参数文件,在 `tools/screen.py``STRATEGIES` 字典中添加新策略
64+
- **新筛选策略** → 往 `stock-screener/references/` 加参数文件,在 `src/alphaclaude/tools/screen.py``STRATEGIES` 字典中添加新策略
6565
- **通达信公式内化** → 分析公式逻辑 → 归类到对应场景 reference 中(信号类/筛选类/指标类)

skills/market-analyzer/SKILL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ triggers:
2727
### 阶段 1:数据获取
2828

2929
```
30-
python tools/quote.py market # 大盘概况:指数/涨跌比/成交额
31-
python tools/flow.py north # 北向资金净流入/5日趋势
32-
python tools/flow.py {sector_or_code} # 板块资金流向(按需)
33-
python tools/news.py market # 市场头条新闻
30+
python -m alphaclaude.tools.quote market # 大盘概况:指数/涨跌比/成交额
31+
python -m alphaclaude.tools.flow north # 北向资金净流入/5日趋势
32+
python -m alphaclaude.tools.flow {sector_or_code} # 板块资金流向(按需)
33+
python -m alphaclaude.tools.news market # 市场头条新闻
3434
```
3535

3636
### 阶段 2:情绪周期判定

skills/market-analyzer/references/dragon-head.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010

1111
## 1. 板块领涨地位
1212

13-
`python tools/flow.py {code}` 检查板块排名:
13+
`python -m alphaclaude.tools.flow {code}` 检查板块排名:
1414
- 确认该股所在板块是否为近期涨幅前列
1515
- 确认该股是否在板块启动周期中率先上涨或涨停
1616
- 真正的龙头在上涨日应跑赢板块平均涨幅 2% 以上
1717

1818
## 2. 换手率与动能(关联理念7:强势趋势股放宽)
1919

20-
`python tools/quote.py {code}`
20+
`python -m alphaclaude.tools.quote {code}`
2121
- 龙头股换手率通常 > 5%
2222
- 量比 > 1.5 说明有活跃的交易兴趣
2323
- 换手率 < 2% 不算龙头
@@ -31,7 +31,7 @@
3131

3232
## 4. 新闻催化
3333

34-
`python tools/news.py {code}` 搜索板块级催化剂:
34+
`python -m alphaclaude.tools.news {code}` 搜索板块级催化剂:
3535
- 政策利好、行业事件、龙头企业业绩超预期
3636
- 龙头行情常伴随板块整体催化
3737
- 无催化剂的放量上涨 → 可能是游资短炒,持续性存疑

skills/market-analyzer/references/sector-rotation.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
## 1. 板块资金流向
99

10-
`python tools/flow.py {sector}``python tools/flow.py north`
10+
`python -m alphaclaude.tools.flow {sector}``python -m alphaclaude.tools.flow north`
1111

1212
- **北向资金**:连续流入/流出趋势。北向连续 3 日净流入 → 外资看多;连续流出 → 谨慎
1313
- **主力资金**:近 5 日主力净流入板块排名。持续流入的板块轮动概率更大

skills/market-analyzer/references/sentiment-cycle.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## 1. 换手率分析(情绪热度核心指标)
1212

13-
`python tools/quote.py {code}``python tools/technical.py {code} --all` 获取换手率数据:
13+
`python -m alphaclaude.tools.quote {code}``python -m alphaclaude.tools.technical {code} --all` 获取换手率数据:
1414

1515
| 换手率 | 情绪阶段 | 含义 |
1616
|--------|----------|------|
@@ -32,7 +32,7 @@
3232

3333
## 3. 新闻情绪面分析
3434

35-
`python tools/news.py {code}` 搜索近期新闻,分析情绪倾向:
35+
`python -m alphaclaude.tools.news {code}` 搜索近期新闻,分析情绪倾向:
3636

3737
| 新闻特征 | 情绪判断 |
3838
|----------|----------|
@@ -42,7 +42,7 @@
4242

4343
## 4. 均线收缩与波动率
4444

45-
`python tools/technical.py {code} --all`
45+
`python -m alphaclaude.tools.technical {code} --all`
4646

4747
- MA5/MA10/MA20 三线粘合(均线收缩)→ 蓄势,方向待定,情绪冷淡
4848
- 波动率降至低位(ATR 萎缩)→ 情绪极度低迷,**蓄势爆发前兆**

skills/stock-analyzer/SKILL.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ always_load: true
1919
同时获取三类数据,减少等待:
2020

2121
```
22-
python tools/quote.py {code} # 实时行情:现价/涨幅/换手率/量比/PE/PB
23-
python tools/technical.py {code} --all # 技术指标:MA/MACD/RSI/KDJ/布林带/量价
24-
python tools/news.py {code} # 近期新闻:公告/研报/情绪
22+
python -m alphaclaude.tools.quote {code} # 实时行情:现价/涨幅/换手率/量比/PE/PB
23+
python -m alphaclaude.tools.technical {code} --all # 技术指标:MA/MACD/RSI/KDJ/布林带/量价
24+
python -m alphaclaude.tools.news {code} # 近期新闻:公告/研报/情绪
2525
```
2626

2727
根据用户问题按需追加:
2828

2929
```
30-
python tools/fundamental.py {code} # PE/PB/ROE/营收增速/行业对比
31-
python tools/flow.py {code} # 主力资金/大单方向
30+
python -m alphaclaude.tools.fundamental {code} # PE/PB/ROE/营收增速/行业对比
31+
python -m alphaclaude.tools.flow {code} # 主力资金/大单方向
3232
```
3333

3434
### 阶段 2:趋势与市场环境判定
@@ -65,7 +65,7 @@ python tools/flow.py {code} # 主力资金/大单方向
6565
在做出买入建议前,必须先评估仓位风险:
6666

6767
```
68-
python tools/risk.py {code} --capital {总资金}
68+
python -m alphaclaude.tools.risk {code} --capital {总资金}
6969
```
7070

7171
获取以下约束:
@@ -112,7 +112,7 @@ python tools/risk.py {code} --capital {总资金}
112112
当给出买入/卖出建议且用户确认后,调用 signal 工具提交信号至模拟盘:
113113

114114
```
115-
python tools/signal.py submit \
115+
python -m alphaclaude.tools.signal submit \
116116
--symbol {代码} --action {buy/sell} \
117117
--entry {买入价} --stop {止损价} --target {止盈价} \
118118
--confidence {置信度0-100} --strategy {策略名} \

skills/stock-analyzer/references/advanced.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
## 1. 中枢识别
1717

18-
`python tools/technical.py {code} --all` 获取近 60 日日线数据:
18+
`python -m alphaclaude.tools.technical {code} --all` 获取近 60 日日线数据:
1919
- 识别近期价格的高低点序列,判断当前是否在**震荡中枢**(1 个以上中枢)还是**趋势段**(脱离中枢向上/向下)
2020
- 中枢:连续 3 段走势重叠区间,价格在此区间反复震荡
2121
- 趋势:连续 3 个同级别中枢均向同一方向移动
@@ -73,7 +73,7 @@
7373

7474
## 1. 识别当前浪型
7575

76-
`python tools/technical.py {code} --all` 获取近 120 日日线数据:
76+
`python -m alphaclaude.tools.technical {code} --all` 获取近 120 日日线数据:
7777

7878
**推动浪(1-3-5)识别特征**
7979
- 第 1 浪:趋势反转的第一波,成交量温和放大

skills/stock-analyzer/references/entry-signals.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
### 判定条件
1414

1515
**主信号 — MA5 上穿 MA10**
16-
`python tools/technical.py {code} --all` 返回的均线数据中检查:
16+
`python -m alphaclaude.tools.technical {code} --all` 返回的均线数据中检查:
1717
- MA5 在最近 3 个交易日内上穿 MA10(前一日 MA5 < MA10,当日 MA5 > MA10)
1818
- MA5 当前值 > MA10 当前值
1919

@@ -28,7 +28,7 @@
2828

2929
**量能确认**
3030
- 金叉日成交量高于 5 日均量
31-
-`python tools/quote.py {code}``volume_ratio` > 1.2 为积极信号
31+
-`python -m alphaclaude.tools.quote {code}``volume_ratio` > 1.2 为积极信号
3232

3333
**趋势背景分级**
3434
- 盘整后金叉:最强信号 ⬆⬆
@@ -64,14 +64,14 @@
6464
### 判定条件
6565

6666
**阻力位识别**
67-
`python tools/technical.py {code} --all` 返回数据中识别:
67+
`python -m alphaclaude.tools.technical {code} --all` 返回数据中识别:
6868
- 20 日高点
6969
- 布林带上轨
7070
- 前期震荡平台顶部(20-60 日内 3 次以上触碰未突破的高点)
7171

7272
**量能确认**
7373
- 当日成交量 > 5 日均量的 **2 倍**
74-
-`python tools/quote.py {code}``volume_ratio` > 2.0
74+
-`python -m alphaclaude.tools.quote {code}``volume_ratio` > 2.0
7575
- 使用 `technical.py` 返回的日线数据计算均量进行交叉验证
7676

7777
**价格确认**
@@ -84,9 +84,9 @@
8484
- 次日回落突破位之下 → 假突破,观望
8585

8686
**风险过滤**
87-
- `python tools/news.py {code}` 检查无重大利空
88-
- PE 不应明显高于行业(`python tools/fundamental.py {code}` 确认)
89-
- `python tools/flow.py {code}` 确认主力资金方向(主力净流入 → 加分)
87+
- `python -m alphaclaude.tools.news {code}` 检查无重大利空
88+
- PE 不应明显高于行业(`python -m alphaclaude.tools.fundamental {code}` 确认)
89+
- `python -m alphaclaude.tools.flow {code}` 确认主力资金方向(主力净流入 → 加分)
9090

9191
### 评分调整
9292

@@ -113,7 +113,7 @@
113113
### 判定条件
114114

115115
**前提条件 — 多头排列(必须)**
116-
`python tools/technical.py {code} --all` 确认:
116+
`python -m alphaclaude.tools.technical {code} --all` 确认:
117117
- MA5 > MA10 > MA20(上升趋势)
118118
- 不满足此条件则不适用此信号
119119

@@ -125,11 +125,11 @@
125125

126126
**反弹信号**
127127
- 当前价格守住均线支撑位(未有效跌破)
128-
-`python tools/quote.py {code}` → 现价 >= MA5 或现价 >= MA10
128+
-`python -m alphaclaude.tools.quote {code}` → 现价 >= MA5 或现价 >= MA10
129129
- MA5 乖离率 < 2% → 最佳买入区间
130130

131131
**确认条件**
132-
- `python tools/news.py {code}` 无利空消息
132+
- `python -m alphaclaude.tools.news {code}` 无利空消息
133133
- 获利比例 50-80% 为健康筹码区间
134134

135135
### 评分调整
@@ -158,13 +158,13 @@
158158
### 判定条件
159159

160160
**持续下跌确认**
161-
`python tools/technical.py {code} --all` 获取 30 日日线数据:
161+
`python -m alphaclaude.tools.technical {code} --all` 获取 30 日日线数据:
162162
- 股价从 20 日高点到近期低点跌幅 > 15%
163163
- 趋势状态应为 BEAR 或 STRONG_BEAR
164164

165165
**量能异动**
166166
- 当日成交量 > 5 日均量的 **3 倍**
167-
-`python tools/quote.py {code}``volume_ratio` > 3.0
167+
-`python -m alphaclaude.tools.quote {code}``volume_ratio` > 3.0
168168
- 该异动应出现在前期极度缩量之后(前 5-10 日成交量低迷)
169169

170170
**价格企稳**
@@ -173,8 +173,8 @@
173173
- 最好出现长下影线(下影线长度 > 实体长度),显示买方支撑
174174

175175
**确认因素**
176-
- `python tools/news.py {code}` 确认是否有基本面催化(业绩、政策、行业事件)
177-
- `python tools/fundamental.py {code}` 配合估值判断(低估值 + 底部放量 = 更强信号)
176+
- `python -m alphaclaude.tools.news {code}` 确认是否有基本面催化(业绩、政策、行业事件)
177+
- `python -m alphaclaude.tools.fundamental {code}` 配合估值判断(低估值 + 底部放量 = 更强信号)
178178
- 筹码分布:平均成本接近现价(成本收敛)
179179

180180
### 风险提示
@@ -207,7 +207,7 @@
207207

208208
### 形态定义(最近 5 个交易日)
209209

210-
`python tools/technical.py {code} --all` 获取最近 10 日 K 线数据(OHLC):
210+
`python -m alphaclaude.tools.technical {code} --all` 获取最近 10 日 K 线数据(OHLC):
211211

212212
1. **第 1 日 — 大阳线**
213213
- 收盘价 > 开盘价

skills/stock-analyzer/references/position-management.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
## 1. 箱体识别
1212

13-
`python tools/technical.py {code} --all` 获取近 60-120 日日线数据:
13+
`python -m alphaclaude.tools.technical {code} --all` 获取近 60-120 日日线数据:
1414

1515
- **箱体顶部(阻力位)**:近期多次触碰但未有效突破的高点连线。通常为 20-60 日内 3 次以上的高点聚集区域。
1616
- **箱体底部(支撑位)**:近期多次下探但未有效跌破的低点连线。通常为 20-60 日内 3 次以上的低点聚集区域。
@@ -19,7 +19,7 @@
1919

2020
## 2. 当前位置判断
2121

22-
`python tools/quote.py {code}` 获取现价,与箱体边界对比:
22+
`python -m alphaclaude.tools.quote {code}` 获取现价,与箱体边界对比:
2323

2424
| 区域 | 判定条件 | 操作 |
2525
|------|----------|------|

0 commit comments

Comments
 (0)