Files
Hermes-Skills/lottery-hk/scripts/verify_lottery.sh
T
mike 913d1945d4 feat: 迁移 trading 相关脚本到 skill 仓库 (第2批: 🟡 中优先级)
【迁移内容】
- dividend-investing/scripts/dca_monitor.py + dca_monitor_us.sh
- dividend-scanner/scripts/scan_cn.{py,sh} + scan_hk.sh + scan_us.sh
- okx-auto-position/scripts/signal_queue_retry.sh
- lottery-hk/scripts/verify_lottery.sh
- longbridge-cli/scripts/longport_http.py (公共模块)

【配套修改】
- 5 个 cron 任务 script 路径更新 (jobs.json):
  - 8929ca09 (DCA港股上午) → dividend-investing/scripts/dca_monitor.py
  - 9469c128 (DCA港股下午) → dividend-investing/scripts/dca_monitor.py
  - 3a4bef2c (DCA美股凌晨) → dividend-investing/scripts/dca_monitor_us.sh
  - a82a3ab0 (signal-queue-retry) → okx-auto-position/scripts/
  - b4868849 (lottery-verify-result) → lottery-hk/scripts/

【删除】本地 ~/.hermes/scripts/{dca_monitor,scan_*,signal_queue_retry,verify_lottery,longport_http}
【未迁移】scan_cn/hk/us 仍需挂 cron, 暂不删 (走 scanner skill)
2026-07-24 11:42:13 +08:00

97 lines
3.5 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# 核验当前期预测 vs 实际开奖,记录命中率
# 22:30 北京时间(开奖21:30后1小时)跑
set -e
DB="$HOME/.hermes/trading/lottery.db"
OUT_DIR="$HOME/.hermes/cron/output/lottery-verify"
mkdir -p "$OUT_DIR"
# 当前期号 - 优先代理,失败直连(VPS 出口有时被墙)
QI=$(curl -s --proxy http://127.0.0.1:7890 --max-time 8 "https://btc.tktk.app/data/v_xg.json" 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('Qi',''))" 2>/dev/null)
if [ -z "$QI" ]; then
QI=$(curl -s --noproxy '*' --max-time 8 "https://btc.tktk.app/data/v_xg.json" 2>/dev/null | python3 -c "import json,sys; d=json.load(sys.stdin); print(d.get('Qi',''))" 2>/dev/null)
fi
if [ -z "$QI" ]; then
echo "❌ 无法获取当前期号(代理+直连都失败)"
exit 1
fi
# 实际开奖结果
ACTUAL=$(sqlite3 "$DB" "SELECT n1||','||n2||','||n3||','||n4||','||n5||','||n6||','||special FROM draws WHERE period='$QI';")
if [ -z "$ACTUAL" ]; then
echo "❌ 期号 $QI 还没入库开奖结果"
exit 1
fi
IFS=',' read -r A1 A2 A3 A4 A5 A6 AS <<< "$ACTUAL"
ACTUAL_FLAT="$A1 $A2 $A3 $A4 $A5 $A6"
ACTUAL_SPECIAL="$AS"
# 找对应的分析文件 - 看 Qi 是几(7-19/21的cron跑的就是 Qi-1 期预测)
QI_NUM=$((10#$QI))
PREV_PERIOD=$((QI_NUM - 1))
# 标题格式有几种:'077期热数据采集' / '热数据采集 · 077期' / '077期数据汇总'
# 简单找包含期号+期 的最近文件
ANALYSIS_FILE=$(grep -lE "${PREV_PERIOD}期数据汇总|${PREV_PERIOD}期热数据采集|热数据采集.*${PREV_PERIOD}期" "$HOME/.hermes/cron/output/5bec1f60f77f/"*.md 2>/dev/null | tail -1)
[ -z "$ANALYSIS_FILE" ] && ANALYSIS_FILE=$(grep -l "${PREV_PERIOD}期" "$HOME/.hermes/cron/output/5bec1f60f77f/"*.md 2>/dev/null | tail -1)
OUT_FILE="$OUT_DIR/$(date +%Y-%m-%d_%H-%M-%S)_${QI}.md"
{
echo "## 🎯 核验报告 | $QI期"
echo ""
echo "**开奖时间**: $(date +%Y-%m-%d) 21:30 北京"
echo "**核验时间**: $(date +%Y-%m-%d) 22:30 北京"
echo ""
echo "### 实际开奖"
echo "| 位置 | 号码 |"
echo "|------|------|"
echo "| 平码 | $A1 · $A2 · $A3 · $A4 · $A5 · $A6 |"
echo "| 特码 | **$AS** |"
echo ""
if [ -n "$ANALYSIS_FILE" ]; then
echo "### 分析文件"
echo "📄 $ANALYSIS_FILE"
echo ""
echo "### 预测 vs 实际"
PREDICTED_SPECIAL=$(grep -o "特码重点.*\*\*[0-9]\+\*\*\|特码.*\*\*[0-9]\+\*\*" "$ANALYSIS_FILE" | head -1)
PREDICTED_FLAT=$(grep "平码优先" "$ANALYSIS_FILE" | head -1)
echo "**预测**: $PREDICTED_SPECIAL · $PREDICTED_FLAT"
echo ""
echo "### 命中分析"
HIT_SPECIAL="❌ 未中"
if echo "$PREDICTED_SPECIAL" | grep -q "\*\*$AS\*\*"; then
HIT_SPECIAL="✅ **特码命中**"
fi
echo "- 特码 $AS: $HIT_SPECIAL"
HIT_FLAT=$(echo "$ACTUAL_FLAT" | tr ' ' '\n' | while read n; do
if echo "$PREDICTED_FLAT" | grep -q "\*\*$n\*\*\|\b$n\b"; then
echo "✅ $n"
fi
done | tr '\n' ' ')
echo "- 平码命中: ${HIT_FLAT:-}"
TOTAL_HIT=$(echo "$ACTUAL_FLAT" | tr ' ' '\n' | while read n; do
if grep -qE "\*\*$n\*\*| $n[、,]|\b$n( |$)" "$ANALYSIS_FILE"; then
echo "1"
fi
done | wc -l)
echo ""
echo "**总命中**: 特码 + 平码 共 $((TOTAL_HIT+0)) / 7 球"
else
echo "### ⚠️ 未找到分析文件"
echo " 查找路径: $HOME/.hermes/cron/output/5bec1f60f77f/"
echo " 期号: $QI"
fi
echo ""
echo "---"
echo "_生成时间: $(date '+%Y-%m-%d %H:%M:%S')_"
} > "$OUT_FILE"
cat "$OUT_FILE"