From 4774b0d53f055dc85b8d927f2a08842e98d580fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=9F=A5=E5=BE=AE?= Date: Sun, 21 Jun 2026 01:29:43 +0800 Subject: [PATCH] =?UTF-8?q?mofin=5Fcollect:=20=E9=87=87=E9=9B=86=E9=93=BE?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E7=9B=98=E5=89=8D=E5=8D=88=E5=90=8E?= =?UTF-8?q?cron=E5=B7=B2=E5=B0=B1=E7=BB=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mofin_collect.py | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 mofin_collect.py diff --git a/mofin_collect.py b/mofin_collect.py new file mode 100644 index 0000000..3fac27d --- /dev/null +++ b/mofin_collect.py @@ -0,0 +1,45 @@ +#!/usr/bin/env python3 +"""mofin_collect.py — MoFin 数据采集链 + +每轮盯盘 cron 前运行,顺序执行: + 1. market_watch — 拉90个行业板块数据 + 2. trend_detector — 检测17种信号 + 3. xiaoguo_news_processor — 搜新闻+小果分析 +""" + +import subprocess, sys, time +from pathlib import Path + +BASE = Path(__file__).parent.parent if "hermes" in str(Path(__file__).resolve()) else Path(__file__).parent + +SCRIPTS = [ + ("market_watch.py", 60), + ("trend_detector.py", 10), + ("xiaoguo_news_processor.py", 60), +] + +for script, timeout in SCRIPTS: + path = BASE / script + if not path.exists(): + path = Path("/home/hmo/MoFin") / script + print(f"--- {script} ---", flush=True) + start = time.time() + try: + result = subprocess.run( + [sys.executable, str(path)], + capture_output=True, text=True, timeout=timeout + ) + elapsed = time.time() - start + if result.returncode == 0: + print(f"OK ({elapsed:.0f}s)", flush=True) + if result.stdout.strip(): + for line in result.stdout.strip().split("\n")[-3:]: + print(f" {line}", flush=True) + else: + print(f"FAIL ({elapsed:.0f}s): {result.stderr[:200]}", flush=True) + except subprocess.TimeoutExpired: + print(f"TIMEOUT ({timeout}s)", flush=True) + except Exception as e: + print(f"ERROR: {e}", flush=True) + +print("采集链完成", flush=True)