Install
openclaw skills install hk-intraday-trading基于盘前选股和实时行情,自动生成港股日内交易买入、卖出、止损价格及复盘结果,支持飞书消息推送。
openclaw skills install hk-intraday-trading盘前选股 → 盘中执行 → 盘后复盘
| 结果 | 说明 | 触发条件 |
|---|---|---|
| 没有成交 | 未触发买入价,未买入 | 最低价 > 目标买入价 |
| 买入后止损 | 触发止损价卖出 | 最低价 <= 买入价 AND 最低价 <= 止损价 |
| 买入后卖出 | 触发卖出价止盈 | 最低价 <= 买入价 AND 最高价 >= 卖出价 |
注意:自动复盘系统会自动根据当日行情判断结果,无需手动记录
| 数据源 | 状态 | 测试日期 | 说明 |
|---|---|---|---|
| 东方财富 API | ✅ 可用 | 2026-03-13 | 免费,无需 API Key,稳定可靠 |
| 腾讯财经 API | ✅ 可用 | 2026-03-13 | 免费,直接 HTTP 请求 |
| easyquotation 库 | ✅ 可用 | 2026-03-13 | 封装腾讯财经 API,易于使用 |
| finance-data skill | ⚠️ 不适用 | - | 仅提供历史数据,不适合实时选股 |
https://push2.eastmoney.com/api/qt/stock/getsecid=116.{股票代码} (116 代表港股)fields=f43,f44,f45,f46,f47,f48,f60,f169,f170,f171,f177| 字段 | 说明 |
|---|---|
| f43 | 当前价格(需除以1000) |
| f44 | 最高价(需除以1000) |
| f45 | 最低价(需除以1000) |
| f47 | 成交量 |
| f170 | 涨跌幅(需除以100) |
| f177 | 振幅(需除以100) |
测试命令:
curl -s "https://push2.eastmoney.com/api/qt/stock/get?secid=116.00700&fields=f43,f44,f45,f170,f177,f47"
测试结果:
{"data": {"f43": 545500, "f44": 551500, "f45": 543500, "f47": 2895136, "f170": -18, "f177": 384}}
✅ 解析:价格 545.5港元,涨跌幅 -1.8%,振幅 3.84%
https://qt.gtimg.cn/q=hk{股票代码}测试命令:
curl -s "https://qt.gtimg.cn/q=hk00700"
测试结果:✅ 可用,返回包含价格、涨跌幅、成交量等数据
pip install easyquotationimport easyquotation
quote = easyquotation.use('hkquote')
data = quote.stocks(['00700', '09988'])
测试结果:
✅ easyquotation 可用:
00700 腾讯控股: price=545.0, Pchange=-1.5, Amp=1.46
09988 阿里巴巴: price=132.2, Pchange=0.6, Amp=1.67
基于以下指标进行选股:
涨跌幅 (Pchange)
振幅 (Amp)
成交量 (amount)
技术指标
# 伪代码
1. 获取股票池(25只主流港股)
2. 调用东方财富API获取实时数据
3. 过滤条件:
- 涨跌幅 > -3%
- 振幅 >= 1%
- 成交量 >= 300万
- RSI 在 30-70 之间
4. 对满足条件的股票进行评分
5. 按评分排序,选出最高分的股票
6. 计算交易价格(买入价、卖出价、止损价)
7. 生成交易计划并推送
总分 100 分,各指标分配:
| 指标 | 分数范围 | 评分规则 |
|---|---|---|
| 涨跌幅 | 0-30分 | -2% |
| 波动性 | 0-25分 | 2%~4%振幅得20分,1.5%~2%得15分 |
| 流动性 | 0-15分 | 成交量越高分数越高 |
| 技术面 | 0-20分 | RSI在40-60得15分,行业加成 |
| 综合 | 0-10分 | 数据完整性奖励 |
评分 >= 75:强烈买入信号 评分 65-74:关注 评分 55-64:持有 评分 < 55:观望
基于股票的振幅(ATR)计算交易价格:
# 输入参数
current_price = 当日收盘价或当前价
atr_pct = 振幅 / 100 # 转换为小数
# 根据评分确定目标收益和止损比例
if score >= 80:
target_gain_pct = atr_pct * 0.8 # 目标获取80%振幅
stop_loss_pct = atr_pct * 0.4 # 止损40%振幅
elif score >= 70:
target_gain_pct = atr_pct * 0.6
stop_loss_pct = atr_pct * 0.5
elif score >= 60:
target_gain_pct = atr_pct * 0.5
stop_loss_pct = atr_pct * 0.6
else:
target_gain_pct = atr_pct * 0.4
stop_loss_pct = atr_pct * 0.7
# 计算交易价格
buy_price = round(current_price * 0.995, 3) # 比当前价低0.5%买入
sell_target = round(current_price * (1 + target_gain_pct), 3) # 卖出目标
stop_loss = round(current_price * (1 - stop_loss_pct), 3) # 止损价格
# 风险收益比
risk_reward_ratio = target_gain_pct / stop_loss_pct
需要获取以下数据:
交易计划数据(选股时生成)
当日实际行情数据(从东方财富 API 获取)
自动判断:根据当日行情自动判断交易结果,无需手动输入
结果类型(只有3种):
| 结果 | 说明 | 触发条件 |
|---|---|---|
| 没有成交 | 未触发买入价,未买入 | 最低价 > 目标买入价 |
| 买入后止损 | 触发止损价卖出 | 最低价 <= 买入价 AND 最低价 <= 止损价 |
| 买入后卖出 | 触发卖出价止盈 | 最低价 <= 买入价 AND 最高价 >= 卖出价 |
自动判断脚本:
# 自动复盘(默认昨天)
python scripts/auto_review.py
# 指定日期复盘
python scripts/auto_review.py --date 2026-03-13
自动判断流程:
判断逻辑:
# 自动判断伪代码
if 最低价 <= 目标买入价:
# 触发了买入
if 最高价 >= 目标卖出价:
result = "sell_achieved" # 买入后卖出(止盈)
elif 最低价 <= 止损价:
result = "stop_loss" # 买入后止损
else:
result = "sell_achieved" # 持有到收盘,按收盘价计算收益
else:
# 没有触发买入价
result = "no_buy" # 没有成交
| 结果 | 触发条件 | 记录方式 |
|---|---|---|
| 没有成交 | 最低价 > 目标买入价 | no_buy |
| 买入后止盈 | 最低价 <= 买入价 AND 最高价 >= 卖出价 | sell_achieved |
| 买入后止损 | 最低价 <= 买入价 AND 最低价 <= 止损价 | stop_loss |
注:
hold_to_close(持有到收盘)归入sell_achieved的边界情况,最终统计时归为止盈未触发。
根据复盘结果,反推选股策略问题:
问题诊断:
优化建议:
问题诊断:
优化建议:
问题诊断:
优化建议:
https://open.feishu.cn/open-apis/bot/v2/hook/{webhook_id})feishu_config.json:{
"enabled": true,
"webhook_url": "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"secret": "your_secret_key",
"notify_types": {
"selection": true,
"review": true,
"error": true
},
"message_format": "rich"
}
app_id 和 app_secret{
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "🎯 港股选股结果",
"content": [
[
{"tag": "text", "text": "🏆 首选股票:"},
{"tag": "text", "text": "00700 腾讯控股", "bold": true}
],
[
{"tag": "text", "text": "💰 交易计划:"}
],
[
{"tag": "text", "text": "买入价:"},
{"tag": "text", "text": "¥380.50", "color": "blue"}
],
[
{"tag": "text", "text": "卖出目标:"},
{"tag": "text", "text": "¥390.00 (+2.5%)", "color": "green"}
],
[
{"tag": "text", "text": "止损价:"},
{"tag": "text", "text": "¥375.00 (-1.5%)", "color": "red"}
],
[
{"tag": "text", "text": "风险收益比:"},
{"tag": "text", "text": "1.67:1"}
]
]
}
}
}
}
{
"msg_type": "post",
"content": {
"post": {
"zh_cn": {
"title": "📊 港股复盘报告",
"content": [
[
{"tag": "text", "text": "📈 交易统计:"}
],
[
{"tag": "text", "text": "• 买入达成:1/1 (100%)"}
],
[
{"tag": "text", "text": "• 卖出达成:1/1 (100%)"}
],
[
{"tag": "text", "text": "• 止损触发:0/1 (0%)"}
],
[
{"tag": "text", "text": "✅ 选股策略评价:"}
],
[
{"tag": "text", "text": "今日策略表现良好,选中的股票成功触发止盈"}
]
]
}
}
}
}
# OpenClaw cron 配置
cron:
- name: "港股早盘选股"
schedule: "0 15 * * 1-5" # 周一至周五 09:15
command: "python /path/to/hk_best_picker_real_fixed.py"
on_success:
- type: feishu
message: "选股结果消息"
# OpenClaw cron 配置
cron:
- name: "港股收盘复盘"
schedule: "0 30 * * 1-5" # 周一至周五 16:30
command: "python /path/to/scripts/auto_review.py"
on_success:
- type: feishu
message: "复盘报告消息"
| 消息类型 | 触发条件 | 推送时间 |
|---|---|---|
| 选股结果 | 每日开盘前 | 09:15-09:25 |
| 选股异常 | 选股失败时 | 立即推送 |
| 复盘结果 | 每日收盘后 | 16:30-16:45 |
| 策略预警 | 连续3天选股失败 | 立即推送 |
hk-intraday-trading/
├── SKILL.md # 技能说明文档
├── template.md # 报告模板
├── data/
│ ├── strategy_config.json # 策略配置
│ └── performance_tracking.json # 性能追踪数据
├── scripts/
│ ├── hk_simple_picker.py # 选股脚本(生成交易价格)
│ ├── auto_review.py # 自动复盘脚本 ⭐
│ ├── review_analyzer.py # 复盘分析器
│ ├── trading_cli.py # 交易CLI工具
│ └── ...
├── output/
│ ├── picks/ # 选股结果
│ │ ├── picks_YYYY-MM-DD.json
│ │ └── picks_report_YYYY-MM-DD.md
│ ├── reviews/ # 复盘报告 ⭐
│ │ └── review_YYYY-MM-DD.md
│ └── 复盘分析_YYYY-MM-DD.md
└── examples/
└── sample_report_YYYY-MM-DD.md
| 脚本 | 用途 | 运行时间 |
|---|---|---|
hk_simple_picker.py | 盘前选股,生成交易价格 | 交易日 09:15 |
auto_review.py | 盘后自动复盘,判断结果 | 交易日 16:30 |